diff options
Diffstat (limited to 'plumbing')
-rw-r--r-- | plumbing/protocol/packp/updreq.go | 2 | ||||
-rw-r--r-- | plumbing/protocol/packp/updreq_decode.go | 5 | ||||
-rw-r--r-- | plumbing/protocol/packp/updreq_decode_test.go | 22 | ||||
-rw-r--r-- | plumbing/protocol/packp/updreq_encode_test.go | 22 |
4 files changed, 27 insertions, 24 deletions
diff --git a/plumbing/protocol/packp/updreq.go b/plumbing/protocol/packp/updreq.go index a2deb89..ae08107 100644 --- a/plumbing/protocol/packp/updreq.go +++ b/plumbing/protocol/packp/updreq.go @@ -88,7 +88,7 @@ const ( ) type Command struct { - Name string + Name plumbing.ReferenceName Old plumbing.Hash New plumbing.Hash } diff --git a/plumbing/protocol/packp/updreq_decode.go b/plumbing/protocol/packp/updreq_decode.go index 2ebe2a3..51e8183 100644 --- a/plumbing/protocol/packp/updreq_decode.go +++ b/plumbing/protocol/packp/updreq_decode.go @@ -207,7 +207,10 @@ func parseCommand(b []byte) (*Command, error) { return nil, errInvalidCommandLineLength(len(b)) } - var os, ns, n string + var ( + os, ns string + n plumbing.ReferenceName + ) if _, err := fmt.Sscanf(string(b), "%s %s %s", &os, &ns, &n); err != nil { return nil, errMalformedCommand(err) } diff --git a/plumbing/protocol/packp/updreq_decode_test.go b/plumbing/protocol/packp/updreq_decode_test.go index 6cbab2b..c084334 100644 --- a/plumbing/protocol/packp/updreq_decode_test.go +++ b/plumbing/protocol/packp/updreq_decode_test.go @@ -151,7 +151,7 @@ func (s *UpdReqDecodeSuite) TestInvalidCommandMissingName(c *C) { func (s *UpdReqDecodeSuite) TestOneUpdateCommand(c *C) { hash1 := plumbing.NewHash("1ecf0ef2c2dffb796033e5a02219af86ec6584e5") hash2 := plumbing.NewHash("2ecf0ef2c2dffb796033e5a02219af86ec6584e5") - name := "myref" + name := plumbing.ReferenceName("myref") expected := NewReferenceUpdateRequest() expected.Commands = []*Command{ @@ -173,9 +173,9 @@ func (s *UpdReqDecodeSuite) TestMultipleCommands(c *C) { expected := NewReferenceUpdateRequest() expected.Commands = []*Command{ - {Name: "myref1", Old: hash1, New: hash2}, - {Name: "myref2", Old: plumbing.ZeroHash, New: hash2}, - {Name: "myref3", Old: hash1, New: plumbing.ZeroHash}, + {Name: plumbing.ReferenceName("myref1"), Old: hash1, New: hash2}, + {Name: plumbing.ReferenceName("myref2"), Old: plumbing.ZeroHash, New: hash2}, + {Name: plumbing.ReferenceName("myref3"), Old: hash1, New: plumbing.ZeroHash}, } expected.Packfile = ioutil.NopCloser(bytes.NewReader([]byte{})) @@ -195,9 +195,9 @@ func (s *UpdReqDecodeSuite) TestMultipleCommandsAndCapabilities(c *C) { expected := NewReferenceUpdateRequest() expected.Commands = []*Command{ - {Name: "myref1", Old: hash1, New: hash2}, - {Name: "myref2", Old: plumbing.ZeroHash, New: hash2}, - {Name: "myref3", Old: hash1, New: plumbing.ZeroHash}, + {Name: plumbing.ReferenceName("myref1"), Old: hash1, New: hash2}, + {Name: plumbing.ReferenceName("myref2"), Old: plumbing.ZeroHash, New: hash2}, + {Name: plumbing.ReferenceName("myref3"), Old: hash1, New: plumbing.ZeroHash}, } expected.Capabilities.Add("shallow") expected.Packfile = ioutil.NopCloser(bytes.NewReader([]byte{})) @@ -218,9 +218,9 @@ func (s *UpdReqDecodeSuite) TestMultipleCommandsAndCapabilitiesShallow(c *C) { expected := NewReferenceUpdateRequest() expected.Commands = []*Command{ - {Name: "myref1", Old: hash1, New: hash2}, - {Name: "myref2", Old: plumbing.ZeroHash, New: hash2}, - {Name: "myref3", Old: hash1, New: plumbing.ZeroHash}, + {Name: plumbing.ReferenceName("myref1"), Old: hash1, New: hash2}, + {Name: plumbing.ReferenceName("myref2"), Old: plumbing.ZeroHash, New: hash2}, + {Name: plumbing.ReferenceName("myref3"), Old: hash1, New: plumbing.ZeroHash}, } expected.Capabilities.Add("shallow") expected.Shallow = &hash1 @@ -240,7 +240,7 @@ func (s *UpdReqDecodeSuite) TestMultipleCommandsAndCapabilitiesShallow(c *C) { func (s *UpdReqDecodeSuite) TestWithPackfile(c *C) { hash1 := plumbing.NewHash("1ecf0ef2c2dffb796033e5a02219af86ec6584e5") hash2 := plumbing.NewHash("2ecf0ef2c2dffb796033e5a02219af86ec6584e5") - name := "myref" + name := plumbing.ReferenceName("myref") expected := NewReferenceUpdateRequest() expected.Commands = []*Command{ diff --git a/plumbing/protocol/packp/updreq_encode_test.go b/plumbing/protocol/packp/updreq_encode_test.go index 14f9975..77b715d 100644 --- a/plumbing/protocol/packp/updreq_encode_test.go +++ b/plumbing/protocol/packp/updreq_encode_test.go @@ -37,7 +37,7 @@ func (s *UpdReqEncodeSuite) TestZeroValue(c *C) { func (s *UpdReqEncodeSuite) TestOneUpdateCommand(c *C) { hash1 := plumbing.NewHash("1ecf0ef2c2dffb796033e5a02219af86ec6584e5") hash2 := plumbing.NewHash("2ecf0ef2c2dffb796033e5a02219af86ec6584e5") - name := "myref" + name := plumbing.ReferenceName("myref") r := NewReferenceUpdateRequest() r.Commands = []*Command{ @@ -58,9 +58,9 @@ func (s *UpdReqEncodeSuite) TestMultipleCommands(c *C) { r := NewReferenceUpdateRequest() r.Commands = []*Command{ - {Name: "myref1", Old: hash1, New: hash2}, - {Name: "myref2", Old: plumbing.ZeroHash, New: hash2}, - {Name: "myref3", Old: hash1, New: plumbing.ZeroHash}, + {Name: plumbing.ReferenceName("myref1"), Old: hash1, New: hash2}, + {Name: plumbing.ReferenceName("myref2"), Old: plumbing.ZeroHash, New: hash2}, + {Name: plumbing.ReferenceName("myref3"), Old: hash1, New: plumbing.ZeroHash}, } expected := pktlines(c, @@ -79,9 +79,9 @@ func (s *UpdReqEncodeSuite) TestMultipleCommandsAndCapabilities(c *C) { r := NewReferenceUpdateRequest() r.Commands = []*Command{ - {Name: "myref1", Old: hash1, New: hash2}, - {Name: "myref2", Old: plumbing.ZeroHash, New: hash2}, - {Name: "myref3", Old: hash1, New: plumbing.ZeroHash}, + {Name: plumbing.ReferenceName("myref1"), Old: hash1, New: hash2}, + {Name: plumbing.ReferenceName("myref2"), Old: plumbing.ZeroHash, New: hash2}, + {Name: plumbing.ReferenceName("myref3"), Old: hash1, New: plumbing.ZeroHash}, } r.Capabilities.Add("shallow") @@ -101,9 +101,9 @@ func (s *UpdReqEncodeSuite) TestMultipleCommandsAndCapabilitiesShallow(c *C) { r := NewReferenceUpdateRequest() r.Commands = []*Command{ - {Name: "myref1", Old: hash1, New: hash2}, - {Name: "myref2", Old: plumbing.ZeroHash, New: hash2}, - {Name: "myref3", Old: hash1, New: plumbing.ZeroHash}, + {Name: plumbing.ReferenceName("myref1"), Old: hash1, New: hash2}, + {Name: plumbing.ReferenceName("myref2"), Old: plumbing.ZeroHash, New: hash2}, + {Name: plumbing.ReferenceName("myref3"), Old: hash1, New: plumbing.ZeroHash}, } r.Capabilities.Add("shallow") r.Shallow = &hash1 @@ -122,7 +122,7 @@ func (s *UpdReqEncodeSuite) TestMultipleCommandsAndCapabilitiesShallow(c *C) { func (s *UpdReqEncodeSuite) TestWithPackfile(c *C) { hash1 := plumbing.NewHash("1ecf0ef2c2dffb796033e5a02219af86ec6584e5") hash2 := plumbing.NewHash("2ecf0ef2c2dffb796033e5a02219af86ec6584e5") - name := "myref" + name := plumbing.ReferenceName("myref") packfileContent := []byte("PACKabc") packfileReader := bytes.NewReader(packfileContent) |