-
Notifications
You must be signed in to change notification settings - Fork 534
Conversation
@osklyar we will be happy to accept also the gitignore parser as a contribution. |
@mcuadros Cool. As |
Codecov Report
@@ Coverage Diff @@
## master #429 +/- ##
==========================================
- Coverage 77.77% 77.41% -0.36%
==========================================
Files 124 127 +3
Lines 9027 9140 +113
==========================================
+ Hits 7021 7076 +55
- Misses 1231 1303 +72
+ Partials 775 761 -14
Continue to review full report at Codecov.
|
@osklyar as part of go-git, we have a bunch of parser already so make sense of having all together at: |
@mcuadros It is a fully independent gitignore parser and judging from stars on the one I originally used there is some interest in using such a parser elsewhere. Sticking it deep into plumbing would make it cumbersome where you need to pull a complete go-git dependency just to use the matcher. I am happy to put it where you suggest but then I would keep the original repo. If, however, this remains an independent repo, I would be happy to transfer the ownership to src-d. Let me know. The gitignore code is now complete with tests and documentation, please check if it is ok like this. |
Having one of the parser as dependency may be ending problematic, if a fix is required. I don't see a problem having nested packaged, if they are well document they appear in godoc searches as any other package. github.com/monochromegane/go-gitignore has 17 stars |
Now ready, taking off the WIP label:
|
"gopkg.in/src-d/go-billy.v2" | ||
"gopkg.in/src-d/go-billy.v2/memfs" | ||
"gopkg.in/src-d/go-git.v4/plumbing/format/gitignore" | ||
"github.com/silvertern/geat/client" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops. fixing dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome contribution! Thanks this is something that was really missing and very important.
@@ -0,0 +1,42 @@ | |||
package gitignore_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't use dedicated test packages, can you use just gitignore
as package?
plumbing/format/gitignore/README.md
Outdated
@@ -0,0 +1,71 @@ | |||
# `gitignore` parser and matcher for Go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of a README.md we document the packages as package documentation as:
https://github.com/src-d/go-git/blob/master/plumbing/format/index/doc.go
And this appears at godoc like: https://godoc.org/gopkg.in/src-d/go-git.v4/plumbing/format/index
plumbing/format/gitignore/dir.go
Outdated
|
||
import ( | ||
"strings" | ||
"gopkg.in/src-d/go-billy.v2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separate the import groups
plumbing/format/gitignore/dir.go
Outdated
|
||
// ReadPatterns reads gitignore patterns recursively traversing through the directory | ||
// structure. The result is in the ascending order of priority (last higher). | ||
func ReadPatterns(fs billy.Filesystem, path []string) (patterns []Pattern, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReadPatterns(fs billy.Filesystem, path []string) (p []Pattern, err error)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do (ps []Pattern, err error)
plumbing/format/gitignore/dir.go
Outdated
defer f.Close() | ||
if data, err := ioutil.ReadAll(f); err == nil { | ||
for _, s := range strings.Split(string(data), "\n") { | ||
if !strings.HasPrefix(s, "#") && len(strings.TrimSpace(s)) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you put #
in a constant to give it semantic meaning?
plumbing/format/gitignore/matcher.go
Outdated
@@ -0,0 +1,33 @@ | |||
// gitignore package implements scanning for and parsing of gitignore files in a directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this comment to a doc.go
file, dedicated to the package documentation including the content of the README.md
@@ -0,0 +1,321 @@ | |||
package gitignore_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gitignore
package gitignore_test | ||
|
||
import ( | ||
"gopkg.in/src-d/go-git.v4/plumbing/format/gitignore" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
groups
Can you squash the commit in a meaningful way? The last thing to merge this. :D |
@mcuadros Now squashed into one commit. The process required resetting all the changed on the branch at which point the PR was automatically closed, so I reopened it now with that single commit. |
"io/ioutil" | ||
"strings" | ||
|
||
"gopkg.in/src-d/go-billy.v2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test are failing, the master now use go-billy.v3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you merged the request, I understand you have already updated this? Is there anything left for me to do?
This is a follow up from #420. As I am not sure if the PR approach is the one that you expect, I request feedback on this WIP change before I introduce all the tests, which are the only missing bits.
Improvements on top of the original PR #420:
Worktree
this time.