sabhiram / go-gitignore Goto Github PK
View Code? Open in Web Editor NEWA gitignore parser for go
License: MIT License
A gitignore parser for go
License: MIT License
First of all thanks for the great work ๐
I'll use go-gitignore
in one of my projects and would be nice if the project follows semver tagging style.
Is it possible to append more lines to a GitIgnore struct?
Could be solved by adding a function to merge multiple GitIgnore structs
func MergeGitIgnores(gitIgnores ...*GitIgnore) *GitIgnore
Hi! Quoting the gitignore spec:
An asterisk "*" matches anything except a slash.
Currently, the * walks right over any slashes. See the following example, which uses the common .*
pattern to ignore dotfiles (used, for example, by the linux source). None of the paths should match.
package main
import (
"fmt"
"github.com/sabhiram/go-gitignore"
)
func main() {
ign := ignore.CompileIgnoreLines(".*")
paths := []string{
"/a/b/.c/",
"/.foo/a",
}
for _, p := range paths {
matches := ign.MatchesPath(p)
fmt.Printf("%q - %v\n", p, matches)
}
ign2 := ignore.CompileIgnoreLines("/.*")
paths2 := []string{
".foo/a",
".asd/"}
for _, p := range paths2 {
matches := ign2.MatchesPath(p)
fmt.Printf("%q - %v\n", p, matches)
}
}
@sabhiram do you still maintain this project? Will pull requests be reviewed? I'd be happy to help out with this problem.
๐๐ป
I'm trying to support .gitignore
from the current directory as well as the user's global git ignore (which I'm parsing from ~/.gitconfig
's core.excludesfile
field).
Specifically I want to support whatever is defined in the local .gitignore
and also whatever is in the global one.
The only way I think I'll be able to do that is by using CompileIgnoreFileAndLines
and passing in the local file for the first argument, and then doing a ReadFile
/Split
for the global git ignore file and passing the individual lines.
Would that sound like the right approach to take or would you suggest any other way to achieve this?
Thanks!
Looks like travis ci is no longer free since a month (june 15 2021)
Move to something like github actions or circle ci etc?
Hi, thank you for the library! I noticed that 223ce5d changed the API.
Would you consider releasing v2.0 to mark the API change?
"io/ioutil" is deprecated: As of Go 1.16, the same functionality is now provided by package [io] or package [os], and those implementations should be preferred in new code. See the specific function documentation for details.deprecated(default)
In CompileIgnoreLines
(here), the function includes an error, when there is no actual error case returned. That then forces following methods (like CompileIgnoreFile
) to also return a possible error, when none is possible.
Shouldn't the function call be:
func CompileIgnoreLines(lines ...string) *GitIgnore {
?
looks like they are probably going to be implemented based on MatchesPath
the file is called gitignore, didn't find this library for a while because of the name
Pattern: "?bc"
Path: "abc"
Expected to match, it doesn't
So I'm suggesting one more sibling method for MatchesPath
which should kind of function like
git check-ignore -v filename
i.e. It would be cool if it can return
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.