File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,25 @@ func AllReferencesFilter(_ Reference) bool {
10
10
return true
11
11
}
12
12
13
+ // PrefixFilter returns a `ReferenceFilter` that matches references
14
+ // whose names start with the specified `prefix`, which must match at
15
+ // a component boundary. For example,
16
+ //
17
+ // * Prefix "refs/foo" matches "refs/foo" and "refs/foo/bar" but not
18
+ // "refs/foobar".
19
+ //
20
+ // * Prefix "refs/foo/" matches "refs/foo/bar" but not "refs/foo" or
21
+ // "refs/foobar".
13
22
func PrefixFilter (prefix string ) ReferenceFilter {
23
+ if strings .HasSuffix (prefix , "/" ) {
24
+ return func (r Reference ) bool {
25
+ return strings .HasPrefix (r .Refname , prefix )
26
+ }
27
+ }
28
+
14
29
return func (r Reference ) bool {
15
- return strings .HasPrefix (r .Refname , prefix )
30
+ return strings .HasPrefix (r .Refname , prefix ) &&
31
+ (len (r .Refname ) == len (prefix ) || r .Refname [len (prefix )] == '/' )
16
32
}
17
33
}
18
34
You can’t perform that action at this time.
0 commit comments