Skip to content

Commit

Permalink
Support symlinks matching ** token
Browse files Browse the repository at this point in the history
  • Loading branch information
dpb587-pivotal committed Sep 19, 2016
1 parent 0dc18b2 commit dfce09e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doublestar.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ func doGlob(basedir string, components, matches []string) (m []string, e error)
if components[patIdx] == "**" {
// if the current component is a doublestar, we'll try depth-first
for _, file := range files {
// if symlink, we may want to follow
if file.Mode() & os.ModeSymlink != 0 {
file, err = os.Stat(filepath.Join(basedir, file.Name()))
if err != nil { continue }
}

if file.IsDir() {
if lastComponent {
m = append(m, filepath.Join(basedir, file.Name()))
Expand Down
1 change: 1 addition & 0 deletions doublestar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ var matchTests = []MatchTest{
{"broken-symlink", "broken-symlink", true, nil, true},
{"working-symlink/c/*", "working-symlink/c/d", true, nil, true},
{"working-sym*/*", "working-symlink/c", true, nil, true},
{"b/**/f", "b/symlink-dir/f", true, nil, true},
}

func TestMatch(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions test/b/symlink-dir

0 comments on commit dfce09e

Please sign in to comment.