@@ -2,6 +2,7 @@ package common
22
33import (
44 "os"
5+ "path"
56 "path/filepath"
67 "strings"
78
@@ -10,8 +11,12 @@ import (
1011 "gopkg.in/src-d/go-git.v4/plumbing/format/gitignore"
1112)
1213
13- func ShouldIgnoreFile (repoPath string , fullFilePath string ) (bool , error ) {
14- fileName := filepath .Base (fullFilePath )
14+ func ShouldIgnoreFile (repoPath string , filePath string ) (bool , error ) {
15+ if ! filepath .IsAbs (filePath ) {
16+ filePath = path .Join (repoPath , filePath )
17+ }
18+
19+ fileName := filepath .Base (filePath )
1520 var isTempFile = strings .HasSuffix (fileName , ".swp" ) || // vim
1621 strings .HasPrefix (fileName , "~" ) || // emacs
1722 strings .HasSuffix (fileName , "~" ) || // kate
@@ -23,20 +28,20 @@ func ShouldIgnoreFile(repoPath string, fullFilePath string) (bool, error) {
2328 return true , nil
2429 }
2530
26- relativePath := fullFilePath [len (repoPath )+ 1 :]
31+ relativePath := filePath [len (repoPath )+ 1 :]
2732 if strings .HasPrefix (relativePath , ".git/" ) {
2833 return true , nil
2934 }
3035
31- empty , err := isEmptyFile (fullFilePath )
36+ empty , err := isEmptyFile (filePath )
3237 if err != nil {
3338 return false , tracerr .Wrap (err )
3439 }
3540 if empty {
3641 return true , nil
3742 }
3843
39- return isFileIgnoredByGit (repoPath , fullFilePath )
44+ return isFileIgnoredByGit (repoPath , filePath )
4045}
4146
4247func isFileIgnoredByGit (repoPath string , filePath string ) (bool , error ) {
0 commit comments