@@ -31,6 +31,46 @@ func TestFile_IgnoreConfigsOrRows(t *testing.T) {
3131 assert .Equal (t , "345" , registry .IgnoredConfigs ()[0 ].ID .String ())
3232}
3333
34+ func TestFile_IgnoreConfigsOrRows_Branch (t * testing.T ) {
35+ t .Parallel ()
36+
37+ ctx := t .Context ()
38+ r := newTestRegistry (t )
39+ fs := aferofs .NewMemoryFs ()
40+
41+ require .NoError (t , fs .WriteFile (ctx , filesystem .NewRawFile (`foo/bar1` , "branch/Main" )))
42+
43+ file , err := LoadFile (ctx , fs , r , "foo/bar1" )
44+ require .NoError (t , err )
45+
46+ require .NoError (t , file .IgnoreConfigsOrRows ())
47+
48+ ignored := r .IgnoredBranches ()
49+ require .Len (t , ignored , 1 )
50+ assert .Equal (t , "123" , ignored [0 ].ID .String ())
51+ }
52+
53+ func TestFile_IgnoreConfigsOrRows_BranchWithSlashInName (t * testing.T ) {
54+ t .Parallel ()
55+
56+ ctx := t .Context ()
57+ r := newTestRegistryWithSlashBranch (t )
58+ fs := aferofs .NewMemoryFs ()
59+
60+ require .NoError (t , fs .WriteFile (ctx , filesystem .NewRawFile (`foo/bar1` , "branch/feature/foo" )))
61+
62+ file , err := LoadFile (ctx , fs , r , "foo/bar1" )
63+ require .NoError (t , err )
64+
65+ require .NoError (t , file .IgnoreConfigsOrRows ())
66+
67+ // Branch "feature/foo" should be ignored, not misidentified as a config-row pattern.
68+ ignored := r .IgnoredBranches ()
69+ require .Len (t , ignored , 1 )
70+ assert .Equal (t , "789" , ignored [0 ].ID .String ())
71+ assert .Empty (t , r .IgnoredConfigRows ())
72+ }
73+
3474func Test_applyIgnoredPatterns (t * testing.T ) {
3575 t .Parallel ()
3676 projectState := newTestRegistry (t )
@@ -83,6 +123,20 @@ func Test_applyIgnoredPatterns(t *testing.T) {
83123 },
84124 wantErr : assert .NoError ,
85125 },
126+ {
127+ name : "branch pattern" ,
128+ args : args {
129+ pattern : "branch/Main" ,
130+ },
131+ wantErr : assert .NoError ,
132+ },
133+ {
134+ name : "branch pattern with slash in name" ,
135+ args : args {
136+ pattern : "branch/feature/foo" ,
137+ },
138+ wantErr : assert .NoError ,
139+ },
86140 }
87141 for _ , tt := range tests {
88142 t .Run (tt .name , func (t * testing.T ) {
0 commit comments