Add #include directive to .stignore (fixes #424)
Though breaks #502 in a way, as .stignore is not the only place where stuff gets defined anymore. Though it never was, as .stignore can be placed in each dir, but I think we should phase that out in favor of globbing which means that we can then have a single file, which means that we can have a UI for editing that. Alternative would be as suggested to include a .stglobalignore which is then synced as a normal file, but gets included by default. Then when the UI would have two editors, a local ignore, and a global ignore.
This commit is contained in:
@@ -113,10 +113,10 @@ func loadIgnoreFile(ignFile, base string) []*regexp.Regexp {
|
||||
return nil
|
||||
}
|
||||
defer fd.Close()
|
||||
return parseIgnoreFile(fd, base)
|
||||
return parseIgnoreFile(fd, base, filepath.Dir(ignFile))
|
||||
}
|
||||
|
||||
func parseIgnoreFile(fd io.Reader, base string) []*regexp.Regexp {
|
||||
func parseIgnoreFile(fd io.Reader, base, dir string) []*regexp.Regexp {
|
||||
var exps []*regexp.Regexp
|
||||
scanner := bufio.NewScanner(fd)
|
||||
for scanner.Scan() {
|
||||
@@ -148,6 +148,14 @@ func parseIgnoreFile(fd io.Reader, base string) []*regexp.Regexp {
|
||||
continue
|
||||
}
|
||||
exps = append(exps, exp)
|
||||
} else if strings.HasPrefix(line, "#include ") {
|
||||
includeFile := filepath.Join(dir, strings.Replace(line, "#include ", "", 1))
|
||||
if _, err := os.Stat(includeFile); os.IsNotExist(err) {
|
||||
l.Infoln("Could not open ignore include file", includeFile)
|
||||
} else {
|
||||
includes := loadIgnoreFile(includeFile, base)
|
||||
exps = append(exps, includes...)
|
||||
}
|
||||
} else {
|
||||
// Path name or pattern, add it so it matches files both in
|
||||
// current directory and subdirs.
|
||||
|
||||
Reference in New Issue
Block a user