File tree 2 files changed +4
-2
lines changed
2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ func (r ReferenceName) Validate() error {
188
188
189
189
isBranch := r .IsBranch ()
190
190
isTag := r .IsTag ()
191
- for _ , part := range parts {
191
+ for i , part := range parts {
192
192
// rule 6
193
193
if len (part ) == 0 {
194
194
return ErrInvalidReferenceName
@@ -205,7 +205,7 @@ func (r ReferenceName) Validate() error {
205
205
return ErrInvalidReferenceName
206
206
}
207
207
208
- if (isBranch || isTag ) && strings .HasPrefix (part , "-" ) { // branches & tags can't start with -
208
+ if (isBranch || isTag ) && strings .HasPrefix (part , "-" ) && ( i == 2 ) { // branches & tags can't start with -
209
209
return ErrInvalidReferenceName
210
210
}
211
211
}
Original file line number Diff line number Diff line change @@ -115,6 +115,8 @@ func (s *ReferenceSuite) TestValidReferenceNames(c *C) {
115
115
"refs/pulls/1/abc.123" ,
116
116
"refs/pulls" ,
117
117
"refs/-" , // should this be allowed?
118
+ "refs/ab/-testing" ,
119
+ "refs/123-testing" ,
118
120
}
119
121
for _ , v := range valid {
120
122
c .Assert (v .Validate (), IsNil )
You can’t perform that action at this time.
0 commit comments