Skip to content

Commit

Permalink
check matches against full directory name
Browse files Browse the repository at this point in the history
  • Loading branch information
piranha committed Jun 11, 2013
1 parent 7e06760 commit 8f87061
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ supported as replacement, no regexp submatch support yet (planned, though).

## Changelog

- 1.2
- `.gitignore` fixes will never end it seems, another one
- 1.1
- Another `.gitignore` improvement
- 1.0
Expand Down
4 changes: 2 additions & 2 deletions goreplace.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

var (
Author = "Alexander Solovyov"
Version = "1.1"
Version = "1.2"

byteNewLine = []byte("\n")
)
Expand Down Expand Up @@ -158,7 +158,7 @@ func (v *GRVisitor) Walker(errors chan<- error) filepath.WalkFunc {
}

func (v *GRVisitor) VisitDir(fn string, fi os.FileInfo) bool {
return !v.ignoreFileMatcher.Match(fi.Name(), true)
return !v.ignoreFileMatcher.Match(fn, true)
}

func (v *GRVisitor) VisitFile(fn string, fi os.FileInfo) {
Expand Down
1 change: 1 addition & 0 deletions matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ type GitMatcher struct {
}

// many thanks to Steve Losh for this algorithm
// https://github.com/sjl/friendly-find/blob/master/ffind#L167-216
func gitGlobRe(s string) *regexp.Regexp {
var pat bytes.Buffer
if strings.Contains(s, "/") {
Expand Down
15 changes: 13 additions & 2 deletions tests/main.t
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ Check that fnmatch-style gitignore patterns are handled:
$ mkdir .git
$ mkdir -p one/two
$ echo test > one/two/three
$ gr st
$ gr test
one/two/three
1:test
$ echo "one/*" > .gitignore
$ gr st
$ gr test
$ cd ..

Check plain text searching:
Expand All @@ -62,3 +62,14 @@ Check plain text searching:
test
1:\d
$ cd ..

Check that anchored directories are properly ignored:

$ mkdir nested && cd nested
$ mkdir .git
$ mkdir -p one/two
$ echo test > one/two/three
$ echo "/one/two" > .gitignore
$ gr test
$ cd ..

0 comments on commit 8f87061

Please sign in to comment.