aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/protocol
diff options
context:
space:
mode:
authorJohn Cai <jcai@gitlab.com>2021-11-03 14:04:06 -0400
committerJohn Cai <jcai@gitlab.com>2021-11-03 15:13:09 -0400
commit589a41ceedfa89e1ff334a969d1beb28cb731de9 (patch)
treef568b7430586771a49bb1e714bee432ed9596deb /plumbing/protocol
parent3211a7a12a0ec2922d257fb14f09c6ecfb0b7c77 (diff)
downloadgo-git-589a41ceedfa89e1ff334a969d1beb28cb731de9.tar.gz
Add Atomic to push options
push --atomic allows a push to succeed or fail atomically. If one ref fails, the whole push fails. This commit allows the user to set Atomic as an option for a push.
Diffstat (limited to 'plumbing/protocol')
-rw-r--r--plumbing/protocol/packp/updreq_encode_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/plumbing/protocol/packp/updreq_encode_test.go b/plumbing/protocol/packp/updreq_encode_test.go
index 6ba0043..4370b79 100644
--- a/plumbing/protocol/packp/updreq_encode_test.go
+++ b/plumbing/protocol/packp/updreq_encode_test.go
@@ -170,3 +170,22 @@ func (s *UpdReqEncodeSuite) TestPushOptions(c *C) {
s.testEncode(c, r, expected)
}
+
+func (s *UpdReqEncodeSuite) TestPushAtomic(c *C) {
+ hash1 := plumbing.NewHash("1ecf0ef2c2dffb796033e5a02219af86ec6584e5")
+ hash2 := plumbing.NewHash("2ecf0ef2c2dffb796033e5a02219af86ec6584e5")
+ name := plumbing.ReferenceName("myref")
+
+ r := NewReferenceUpdateRequest()
+ r.Capabilities.Set(capability.Atomic)
+ r.Commands = []*Command{
+ {Name: name, Old: hash1, New: hash2},
+ }
+
+ expected := pktlines(c,
+ "1ecf0ef2c2dffb796033e5a02219af86ec6584e5 2ecf0ef2c2dffb796033e5a02219af86ec6584e5 myref\x00atomic",
+ pktline.FlushString,
+ )
+
+ s.testEncode(c, r, expected)
+}