@@ -2,6 +2,7 @@ package common
2
2
3
3
import (
4
4
"os"
5
+ "path"
5
6
"path/filepath"
6
7
"strings"
7
8
@@ -10,8 +11,12 @@ import (
10
11
"gopkg.in/src-d/go-git.v4/plumbing/format/gitignore"
11
12
)
12
13
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 )
15
20
var isTempFile = strings .HasSuffix (fileName , ".swp" ) || // vim
16
21
strings .HasPrefix (fileName , "~" ) || // emacs
17
22
strings .HasSuffix (fileName , "~" ) || // kate
@@ -23,20 +28,20 @@ func ShouldIgnoreFile(repoPath string, fullFilePath string) (bool, error) {
23
28
return true , nil
24
29
}
25
30
26
- relativePath := fullFilePath [len (repoPath )+ 1 :]
31
+ relativePath := filePath [len (repoPath )+ 1 :]
27
32
if strings .HasPrefix (relativePath , ".git/" ) {
28
33
return true , nil
29
34
}
30
35
31
- empty , err := isEmptyFile (fullFilePath )
36
+ empty , err := isEmptyFile (filePath )
32
37
if err != nil {
33
38
return false , tracerr .Wrap (err )
34
39
}
35
40
if empty {
36
41
return true , nil
37
42
}
38
43
39
- return isFileIgnoredByGit (repoPath , fullFilePath )
44
+ return isFileIgnoredByGit (repoPath , filePath )
40
45
}
41
46
42
47
func isFileIgnoredByGit (repoPath string , filePath string ) (bool , error ) {
0 commit comments