Skip to content

Commit 898fbb2

Browse files
Merge pull request #6083 from danegsta/danegsta/windowsExtendedGlob
Allow extendedGlob to work with Windows paths
2 parents e4d3dc0 + 74cfd3c commit 898fbb2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

copier/copier.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ func extendedGlob(pattern string) (matches []string, err error) {
7070
components := []string{}
7171
dir := pattern
7272
file := ""
73-
for dir != "" && dir != string(os.PathSeparator) {
73+
for dir != filepath.VolumeName(dir) && dir != string(os.PathSeparator) {
7474
dir, file = filepath.Split(dir)
75-
components = append([]string{file}, components...)
75+
if file != "" {
76+
components = append([]string{file}, components...)
77+
}
7678
dir = strings.TrimSuffix(dir, string(os.PathSeparator))
7779
}
78-
patterns := []string{string(os.PathSeparator)}
80+
patterns := []string{filepath.VolumeName(dir) + string(os.PathSeparator)}
7981
for i := range components {
8082
var nextPatterns []string
8183
if components[i] == "**" {

copier/xattrs_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build linux || netbsd || freebsd || darwin
2+
13
package copier
24

35
import (

0 commit comments

Comments
 (0)