chand1012/git2gpt

Glob Patterns don't work on Windows

Closed this issue · 0 comments

I believe the following code is to blame:

git2gpt/prompt/prompt.go

Lines 40 to 73 in f97ec38

func getIgnoreList(ignoreFilePath string) ([]string, error) {
var ignoreList []string
file, err := os.Open(ignoreFilePath)
if err != nil {
return ignoreList, err
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line == "" || strings.HasPrefix(line, "#") {
continue
}
// if the line ends with a slash, add a globstar to the end
if strings.HasSuffix(line, "/") {
line = line + "**"
}
// remove all preceding slashes
line = strings.TrimPrefix(line, "/")
ignoreList = append(ignoreList, line)
}
return ignoreList, scanner.Err()
}
func shouldIgnore(filePath string, ignoreList []string) bool {
for _, pattern := range ignoreList {
g := glob.MustCompile(pattern)
if g.Match(filePath) {
return true
}
}
return false
}

I want the functionality to be the exact same on Windows and on Unix systems.