浏览代码

vendor: Update gobwas/glob to fix question mark handling

Jakob Borg 9 年之前
父节点
当前提交
4b3adfa21c
共有 3 个文件被更改,包括 36 次插入12 次删除
  1. 32 0
      lib/ignore/ignore_test.go
  2. 3 11
      vendor/github.com/gobwas/glob/match/row.go
  3. 1 1
      vendor/manifest

+ 32 - 0
lib/ignore/ignore_test.go

@@ -769,3 +769,35 @@ func TestIssue3674(t *testing.T) {
 		}
 	}
 }
+
+func TestGobwasGlobIssue18(t *testing.T) {
+	stignore := `
+	a?b
+	bb?
+	`
+
+	testcases := []struct {
+		file    string
+		matches bool
+	}{
+		{"ab", false},
+		{"acb", true},
+		{"asdb", false},
+		{"bb", false},
+		{"bba", true},
+		{"bbaa", false},
+	}
+
+	pats := New(true)
+	err := pats.Parse(bytes.NewBufferString(stignore), ".stignore")
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	for _, tc := range testcases {
+		res := pats.Match(tc.file).IsIgnored()
+		if res != tc.matches {
+			t.Errorf("Matches(%q) == %v, expected %v", tc.file, res, tc.matches)
+		}
+	}
+}

+ 3 - 11
vendor/github.com/gobwas/glob/match/row.go

@@ -45,12 +45,11 @@ func (self Row) lenOk(s string) bool {
 	var i int
 	for _ = range s {
 		i++
-		if i >= self.RunesLength {
-			return true
+		if i > self.RunesLength {
+			return false
 		}
 	}
-
-	return false
+	return self.RunesLength == i
 }
 
 func (self Row) Match(s string) bool {
@@ -62,21 +61,14 @@ func (self Row) Len() (l int) {
 }
 
 func (self Row) Index(s string) (int, []int) {
-	if !self.lenOk(s) {
-		return -1, nil
-	}
-
 	for i := range s {
-		// this is not strict check but useful
 		if len(s[i:]) < self.RunesLength {
 			break
 		}
-
 		if self.matchAll(s[i:]) {
 			return i, self.Segments
 		}
 	}
-
 	return -1, nil
 }
 

+ 1 - 1
vendor/manifest

@@ -134,7 +134,7 @@
 		{
 			"importpath": "github.com/gobwas/glob",
 			"repository": "https://github.com/gobwas/glob",
-			"revision": "ce6abff51712df5da11095fb41dd4b0353559797",
+			"revision": "0354991b92587e2742549d3036f3b5bae5ab03f2",
 			"branch": "master",
 			"notests": true
 		},