@@ -5,9 +5,11 @@ import (
5
5
6
6
"github.com/go-git/go-git/v5/plumbing"
7
7
"github.com/go-git/go-git/v5/plumbing/format/pktline"
8
+ "github.com/go-git/go-git/v5/plumbing/protocol/packp/capability"
8
9
9
- . "gopkg.in/check.v1"
10
10
"io/ioutil"
11
+
12
+ . "gopkg.in/check.v1"
11
13
)
12
14
13
15
type UpdReqEncodeSuite struct {}
@@ -142,3 +144,29 @@ func (s *UpdReqEncodeSuite) TestWithPackfile(c *C) {
142
144
143
145
s .testEncode (c , r , expected )
144
146
}
147
+
148
+ func (s * UpdReqEncodeSuite ) TestPushOptions (c * C ) {
149
+ hash1 := plumbing .NewHash ("1ecf0ef2c2dffb796033e5a02219af86ec6584e5" )
150
+ hash2 := plumbing .NewHash ("2ecf0ef2c2dffb796033e5a02219af86ec6584e5" )
151
+ name := plumbing .ReferenceName ("myref" )
152
+
153
+ r := NewReferenceUpdateRequest ()
154
+ r .Capabilities .Set (capability .PushOptions )
155
+ r .Commands = []* Command {
156
+ {Name : name , Old : hash1 , New : hash2 },
157
+ }
158
+ r .Options = []* Option {
159
+ {Key : "SomeKey" , Value : "SomeValue" },
160
+ {Key : "AnotherKey" , Value : "AnotherValue" },
161
+ }
162
+
163
+ expected := pktlines (c ,
164
+ "1ecf0ef2c2dffb796033e5a02219af86ec6584e5 2ecf0ef2c2dffb796033e5a02219af86ec6584e5 myref\x00 push-options" ,
165
+ pktline .FlushString ,
166
+ "SomeKey=SomeValue" ,
167
+ "AnotherKey=AnotherValue" ,
168
+ pktline .FlushString ,
169
+ )
170
+
171
+ s .testEncode (c , r , expected )
172
+ }
0 commit comments