@@ -23,6 +23,15 @@ func (s *RefSpecSuite) TestRefSpecIsValid(c *C) {
23
23
spec = RefSpec ("refs/heads/master:refs/remotes/origin/master" )
24
24
c .Assert (spec .IsValid (), Equals , true )
25
25
26
+ spec = RefSpec (":refs/heads/master" )
27
+ c .Assert (spec .IsValid (), Equals , true )
28
+
29
+ spec = RefSpec (":refs/heads/*" )
30
+ c .Assert (spec .IsValid (), Equals , false )
31
+
32
+ spec = RefSpec (":*" )
33
+ c .Assert (spec .IsValid (), Equals , false )
34
+
26
35
spec = RefSpec ("refs/heads/*" )
27
36
c .Assert (spec .IsValid (), Equals , false )
28
37
}
@@ -35,18 +44,36 @@ func (s *RefSpecSuite) TestRefSpecIsForceUpdate(c *C) {
35
44
c .Assert (spec .IsForceUpdate (), Equals , false )
36
45
}
37
46
47
+ func (s * RefSpecSuite ) TestRefSpecIsDelete (c * C ) {
48
+ spec := RefSpec (":refs/heads/master" )
49
+ c .Assert (spec .IsDelete (), Equals , true )
50
+
51
+ spec = RefSpec ("+refs/heads/*:refs/remotes/origin/*" )
52
+ c .Assert (spec .IsDelete (), Equals , false )
53
+
54
+ spec = RefSpec ("refs/heads/*:refs/remotes/origin/*" )
55
+ c .Assert (spec .IsDelete (), Equals , false )
56
+ }
57
+
38
58
func (s * RefSpecSuite ) TestRefSpecSrc (c * C ) {
39
59
spec := RefSpec ("refs/heads/*:refs/remotes/origin/*" )
40
60
c .Assert (spec .Src (), Equals , "refs/heads/*" )
61
+
62
+ spec = RefSpec (":refs/heads/master" )
63
+ c .Assert (spec .Src (), Equals , "" )
41
64
}
42
65
43
66
func (s * RefSpecSuite ) TestRefSpecMatch (c * C ) {
44
67
spec := RefSpec ("refs/heads/master:refs/remotes/origin/master" )
45
68
c .Assert (spec .Match (plumbing .ReferenceName ("refs/heads/foo" )), Equals , false )
46
69
c .Assert (spec .Match (plumbing .ReferenceName ("refs/heads/master" )), Equals , true )
70
+
71
+ spec = RefSpec (":refs/heads/master" )
72
+ c .Assert (spec .Match (plumbing .ReferenceName ("" )), Equals , true )
73
+ c .Assert (spec .Match (plumbing .ReferenceName ("refs/heads/master" )), Equals , false )
47
74
}
48
75
49
- func (s * RefSpecSuite ) TestRefSpecMatchBlob (c * C ) {
76
+ func (s * RefSpecSuite ) TestRefSpecMatchGlob (c * C ) {
50
77
spec := RefSpec ("refs/heads/*:refs/remotes/origin/*" )
51
78
c .Assert (spec .Match (plumbing .ReferenceName ("refs/tag/foo" )), Equals , false )
52
79
c .Assert (spec .Match (plumbing .ReferenceName ("refs/heads/foo" )), Equals , true )
0 commit comments