diff options
author | Santiago M. Mola <santi@mola.io> | 2017-06-23 19:20:07 +0200 |
---|---|---|
committer | Santiago M. Mola <santi@mola.io> | 2017-06-23 19:20:07 +0200 |
commit | cb55d396c8fdeae4975592e7bc973c354f73bd63 (patch) | |
tree | 6872ba552358bb1e316de5c6e28067d1e6f77746 /plumbing/protocol | |
parent | ad02bf020460c210660db4fffda7f926b6aae95a (diff) | |
download | go-git-cb55d396c8fdeae4975592e7bc973c354f73bd63.tar.gz |
capability: accept unknown capabilities, fixes #450
GitHub has started using a non-standard capability "early-capabilities"
with agent=git/github-g3daa19f21. This is breaking all go-git operations
on GitHub.
This commit removes validation for known capabilities, so that we can
use non-standard capabilities safely.
Diffstat (limited to 'plumbing/protocol')
-rw-r--r-- | plumbing/protocol/packp/capability/list.go | 6 | ||||
-rw-r--r-- | plumbing/protocol/packp/capability/list_test.go | 10 |
2 files changed, 6 insertions, 10 deletions
diff --git a/plumbing/protocol/packp/capability/list.go b/plumbing/protocol/packp/capability/list.go index 69fdb51..3904a4e 100644 --- a/plumbing/protocol/packp/capability/list.go +++ b/plumbing/protocol/packp/capability/list.go @@ -8,8 +8,6 @@ import ( ) var ( - // ErrUnknownCapability is returned if a unknown capability is given - ErrUnknownCapability = errors.New("unknown capability") // ErrArgumentsRequired is returned if no arguments are giving with a // capability that requires arguments ErrArgumentsRequired = errors.New("arguments required") @@ -119,10 +117,6 @@ func (l *List) Add(c Capability, values ...string) error { } func (l *List) validate(c Capability, values []string) error { - if _, ok := valid[c]; !ok { - return ErrUnknownCapability - } - if requiresArgument[c] && len(values) == 0 { return ErrArgumentsRequired } diff --git a/plumbing/protocol/packp/capability/list_test.go b/plumbing/protocol/packp/capability/list_test.go index 0a0ad26..9665e89 100644 --- a/plumbing/protocol/packp/capability/list_test.go +++ b/plumbing/protocol/packp/capability/list_test.go @@ -58,10 +58,11 @@ func (s *SuiteCapabilities) TestDecodeWithEqual(c *check.C) { c.Assert(cap.Get(Agent), check.DeepEquals, []string{"foo=bar"}) } -func (s *SuiteCapabilities) TestDecodeWithErrUnknownCapability(c *check.C) { +func (s *SuiteCapabilities) TestDecodeWithUnknownCapability(c *check.C) { cap := NewList() err := cap.Decode([]byte("foo")) - c.Assert(err, check.Equals, ErrUnknownCapability) + c.Assert(err, check.IsNil) + c.Assert(cap.Supports(Capability("foo")), check.Equals, true) } func (s *SuiteCapabilities) TestString(c *check.C) { @@ -133,10 +134,11 @@ func (s *SuiteCapabilities) TestAdd(c *check.C) { c.Assert(cap.String(), check.Equals, "symref=foo symref=qux thin-pack") } -func (s *SuiteCapabilities) TestAddErrUnknownCapability(c *check.C) { +func (s *SuiteCapabilities) TestAddUnknownCapability(c *check.C) { cap := NewList() err := cap.Add(Capability("foo")) - c.Assert(err, check.Equals, ErrUnknownCapability) + c.Assert(err, check.IsNil) + c.Assert(cap.Supports(Capability("foo")), check.Equals, true) } func (s *SuiteCapabilities) TestAddErrArgumentsRequired(c *check.C) { |