Start improvements of gitignore logic
@@ -76,7 +76,7 @@ func walkDirectoryParallel(root string, output chan *FileJob) {
var wg sync.WaitGroup
- var isSoloFile bool = false
+ var isSoloFile = false
var all []os.FileInfo
// clean path including trailing slashes
root = filepath.Clean(root)
@@ -89,8 +89,9 @@ func walkDirectoryParallel(root string, output chan *FileJob) {
all, _ = ioutil.ReadDir(root)
}
- // TODO the gitignore should check for further gitignores deeper in the tree
- gitignore, gitignoreerror := gitignore.NewGitIgnore(filepath.Join(root, ".gitignore"))
+ // TODO the gitIgnore should check for further gitignores deeper in the tree
+ gitIgnore, gitIgnoreError := gitignore.NewGitIgnore(filepath.Join(root, ".gitignore"))
+
resetGc := false
var regex *regexp.Regexp
@@ -125,6 +126,13 @@ func walkDirectoryParallel(root string, output chan *FileJob) {
}
}
+ if gitIgnoreError != nil || gitIgnore.Match(filepath.Join(root, f.Name()), true) {
+ if Verbose {
+ printWarn("skipping directory due to git ignore: " + filepath.Join(root, f.Name()))
+ }
+ shouldSkip = true
+ }
+
if !shouldSkip {
wg.Add(1)
go func(toWalk string) {
@@ -152,9 +160,16 @@ func walkDirectoryParallel(root string, output chan *FileJob) {
} else {
fpath = filepath.Join(root, f.Name())
}
- if gitignoreerror != nil || !gitignore.Match(fpath, false) {
shouldSkip := false
+
+ if gitIgnoreError != nil || gitIgnore.Match(fpath, false) {
+ if Verbose {
+ printWarn("skipping file due to git ignore: " + f.Name())
+ }
+ shouldSkip = true
+ }
+
if Exclude != "" {
if regex.Match([]byte(f.Name())) {
if Verbose {
@@ -194,7 +209,6 @@ func walkDirectoryParallel(root string, output chan *FileJob) {
}
}
}
- }
wg.Wait()
close(output)
