From a32ef6afc4128a16eaec5cb40b108e7e59e6fc59 Mon Sep 17 00:00:00 2001 From: Ido-DY <85484711+Ido-DY@users.noreply.github.com> Date: Thu, 2 Sep 2021 17:35:38 +0300 Subject: [PATCH] fix(git-symlink-commits): fix handling symbolic links in a git repository (#612) --- scan/unstaged.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scan/unstaged.go b/scan/unstaged.go index ec200616..3ca16532 100644 --- a/scan/unstaged.go +++ b/scan/unstaged.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "io" + "os" "os/exec" "path/filepath" "strings" @@ -156,6 +157,9 @@ func (us *UnstagedScanner) Scan() (Report, error) { // file in staging has been deleted, aka it is not on the filesystem // so the contents of the file are "" currFileContents = "" + //check if file is symlink + } else if fc, err := os.Readlink(fn); err == nil { + currFileContents = fc } else { workTreeBuf := bytes.NewBuffer(nil) workTreeFile, err := wt.Filesystem.Open(fn)