瀏覽代碼

fix(git-symlink-commits): fix handling symbolic links in a git repository

Ido Markovitz 4 年之前
父節點
當前提交
c8e97d97f9
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      scan/unstaged.go

+ 4 - 0
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)