File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ func (r ReferenceName) Validate() error {
188188
189189 isBranch := r .IsBranch ()
190190 isTag := r .IsTag ()
191- for _ , part := range parts {
191+ for i , part := range parts {
192192 // rule 6
193193 if len (part ) == 0 {
194194 return ErrInvalidReferenceName
@@ -205,7 +205,7 @@ func (r ReferenceName) Validate() error {
205205 return ErrInvalidReferenceName
206206 }
207207
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 -
209209 return ErrInvalidReferenceName
210210 }
211211 }
Original file line number Diff line number Diff line change @@ -115,6 +115,8 @@ func (s *ReferenceSuite) TestValidReferenceNames(c *C) {
115115 "refs/pulls/1/abc.123" ,
116116 "refs/pulls" ,
117117 "refs/-" , // should this be allowed?
118+ "refs/ab/-testing" ,
119+ "refs/123-testing" ,
118120 }
119121 for _ , v := range valid {
120122 c .Assert (v .Validate (), IsNil )
You can’t perform that action at this time.
0 commit comments