From a05244018ae02603c56a27f8f8b7006c0024f7ea Mon Sep 17 00:00:00 2001 From: Anirudh Oppiliappan Date: Mon, 19 Dec 2022 11:36:50 +0530 Subject: git: check for binary files --- git/git.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'git/git.go') diff --git a/git/git.go b/git/git.go index 3756840..34e8a80 100644 --- a/git/git.go +++ b/git/git.go @@ -76,7 +76,13 @@ func (g *GitRepo) FileContent(path string) (string, error) { return "", err } - return file.Contents() + isbin, _ := file.IsBinary() + + if !isbin { + return file.Contents() + } else { + return "Not displaying binary file", nil + } } func (g *GitRepo) Tags() ([]*object.Tag, error) { -- cgit