mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-09-20 07:21:22 +00:00
Merge pull request #136 from cboylan/fix-vendor-regex
Fix IsVendor() regex generation
This commit is contained in:
commit
a53744636a
8
utils.go
8
utils.go
@ -213,23 +213,23 @@ func init() {
|
|||||||
sb := &strings.Builder{}
|
sb := &strings.Builder{}
|
||||||
|
|
||||||
// Start with group 1 - those that started with `^`
|
// Start with group 1 - those that started with `^`
|
||||||
sb.WriteString("(?:^(?:")
|
sb.WriteString("(?:^(?:(?:")
|
||||||
sb.WriteString(caretStrings[0])
|
sb.WriteString(caretStrings[0])
|
||||||
for _, matcher := range caretStrings[1:] {
|
for _, matcher := range caretStrings[1:] {
|
||||||
sb.WriteString(")|(?:")
|
sb.WriteString(")|(?:")
|
||||||
sb.WriteString(matcher)
|
sb.WriteString(matcher)
|
||||||
}
|
}
|
||||||
sb.WriteString("))")
|
sb.WriteString(")))")
|
||||||
sb.WriteString("|")
|
sb.WriteString("|")
|
||||||
|
|
||||||
// Now add group 2 - those that started with `(^|/)`
|
// Now add group 2 - those that started with `(^|/)`
|
||||||
sb.WriteString("(?:(?:^|/)(?:")
|
sb.WriteString("(?:(?:^|/)(?:(?:")
|
||||||
sb.WriteString(caretSegmentStrings[0])
|
sb.WriteString(caretSegmentStrings[0])
|
||||||
for _, matcher := range caretSegmentStrings[1:] {
|
for _, matcher := range caretSegmentStrings[1:] {
|
||||||
sb.WriteString(")|(?:")
|
sb.WriteString(")|(?:")
|
||||||
sb.WriteString(matcher)
|
sb.WriteString(matcher)
|
||||||
}
|
}
|
||||||
sb.WriteString("))")
|
sb.WriteString(")))")
|
||||||
sb.WriteString("|")
|
sb.WriteString("|")
|
||||||
|
|
||||||
// Finally add the rest
|
// Finally add the rest
|
||||||
|
@ -17,6 +17,7 @@ func TestIsVendor(t *testing.T) {
|
|||||||
expected bool
|
expected bool
|
||||||
}{
|
}{
|
||||||
{"cache/", true},
|
{"cache/", true},
|
||||||
|
{"something_cache/", false},
|
||||||
{"random/cache/", true},
|
{"random/cache/", true},
|
||||||
{"cache", false},
|
{"cache", false},
|
||||||
{"dependencies/", true},
|
{"dependencies/", true},
|
||||||
@ -27,6 +28,7 @@ func TestIsVendor(t *testing.T) {
|
|||||||
{"random/dist/", true},
|
{"random/dist/", true},
|
||||||
{"random/dist", false},
|
{"random/dist", false},
|
||||||
{"deps/", true},
|
{"deps/", true},
|
||||||
|
{"foodeps/", false},
|
||||||
{"configure", true},
|
{"configure", true},
|
||||||
{"a/configure", true},
|
{"a/configure", true},
|
||||||
{"config.guess", true},
|
{"config.guess", true},
|
||||||
@ -43,6 +45,7 @@ func TestIsVendor(t *testing.T) {
|
|||||||
{"foo/bar/MochiKit.js", true},
|
{"foo/bar/MochiKit.js", true},
|
||||||
{"foo/bar/dojo.js", true},
|
{"foo/bar/dojo.js", true},
|
||||||
{"foo/env/whatever", true},
|
{"foo/env/whatever", true},
|
||||||
|
{"some/python/venv/", false},
|
||||||
{"foo/.imageset/bar", true},
|
{"foo/.imageset/bar", true},
|
||||||
{"Vagrantfile", true},
|
{"Vagrantfile", true},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user