You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
If you are interested in working on this issue or have submitted a pull request, please leave a comment
Description
gitignore support
Problem to be Addressed
Scanning of filesystem may become a challenging task because there are many folders which are not expected to be scanned, especially folders like node_modules which can contain quadrillion of files
Description of the Preferred Solution
Whenever we are going to scan file or dig into directory we should traverse directories tree to see if there is gitignore somewhere and check if that file or directory isn't there
Something like this one (should be optimized, but describes the idea):
package main
import (
"fmt""log""os""path/filepath"
ignore "github.com/sabhiram/go-gitignore"
)
funcmain() {
// recursive iteration over `os.Args[1]` pathfilepath.Walk(os.Args[1], func(pathstring, info os.FileInfo, errerror) error {
iferr!=nil {
log.Println(err)
}
// path == "/Users/mac/Desktop/demo/obj/Debug/net6.0/logging.AssemblyInfo.cs"// info.Name() == "logging.AssemblyInfo.cs"// inner, walk up till root or found gitignorevargitignore*ignore.GitIgnoreparent:=pathfor {
gitignore, _=ignore.CompileIgnoreFile(filepath.Join(parent, ".gitignore"))
ifgitignore!=nil {
// gitignore found, breaking loopbreak
}
ifparent==filepath.Dir(parent) {
// we are at root and there is no more parents, breaking loopbreak
} else {
parent=filepath.Dir(parent)
}
}
ignored:=falseifgitignore!=nil {
ignored=gitignore.MatchesPath(path)
}
fmt.Printf("%v %s\n", ignored, path)
returnnil
})
}
Community Note
Description
gitignore support
Problem to be Addressed
Scanning of filesystem may become a challenging task because there are many folders which are not expected to be scanned, especially folders like node_modules which can contain quadrillion of files
Description of the Preferred Solution
Whenever we are going to scan file or dig into directory we should traverse directories tree to see if there is gitignore somewhere and check if that file or directory isn't there
Something like this one (should be optimized, but describes the idea):
Additional Context
References
The text was updated successfully, but these errors were encountered: