diff options
author | Lukasz Piatkowski <lukaspiatkowski@gmail.com> | 2022-10-20 10:33:47 +0200 |
---|---|---|
committer | Lukasz Piatkowski <lukaspiatkowski@gmail.com> | 2022-11-12 07:24:14 +0100 |
commit | 4fa858619149f14a71cbe9e76f30de84e7a3042a (patch) | |
tree | 15cadcba329a6bccd85788a71be10318b06069de /vendor | |
parent | 3a295f34df0f5a2fda54607e8a3447b835ced65f (diff) |
Update go-git to handle negative refspecs
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/github.com/jesseduffield/go-git/v5/config/refspec.go | 27 | ||||
-rw-r--r-- | vendor/modules.txt | 2 |
2 files changed, 27 insertions, 2 deletions
diff --git a/vendor/github.com/jesseduffield/go-git/v5/config/refspec.go b/vendor/github.com/jesseduffield/go-git/v5/config/refspec.go index 3b0cb77e6..9af7abde5 100644 --- a/vendor/github.com/jesseduffield/go-git/v5/config/refspec.go +++ b/vendor/github.com/jesseduffield/go-git/v5/config/refspec.go @@ -11,11 +11,13 @@ const ( refSpecWildcard = "*" refSpecForce = "+" refSpecSeparator = ":" + refSpecNegative = "^" ) var ( ErrRefSpecMalformedSeparator = errors.New("malformed refspec, separators are wrong") ErrRefSpecMalformedWildcard = errors.New("malformed refspec, mismatched number of wildcards") + ErrRefSpecMalformedNegative = errors.New("malformed negative refspec, one ^ and no separators allowed") ) // RefSpec is a mapping from local branches to remote references. @@ -31,6 +33,24 @@ type RefSpec string // Validate validates the RefSpec func (s RefSpec) Validate() error { spec := string(s) + + if strings.Index(spec, refSpecNegative) == 0 { + // This is a negative refspec + if strings.Count(spec, refSpecNegative) != 1 { + return ErrRefSpecMalformedNegative + } + + if strings.Count(spec, refSpecSeparator) != 0 { + return ErrRefSpecMalformedNegative + } + + if strings.Count(spec, refSpecWildcard) > 1 { + return ErrRefSpecMalformedWildcard + } + + return nil + } + if strings.Count(spec, refSpecSeparator) != 1 { return ErrRefSpecMalformedSeparator } @@ -64,12 +84,17 @@ func (s RefSpec) IsExactSHA1() bool { return plumbing.IsHash(s.Src()) } +// IsNegative returns if the refspec is a negative one +func (s RefSpec) IsNegative() bool { + return s[0] == refSpecNegative[0] +} + // Src return the src side. func (s RefSpec) Src() string { spec := string(s) var start int - if s.IsForceUpdate() { + if s.IsForceUpdate() || s.IsNegative() { start = 1 } else { start = 0 diff --git a/vendor/modules.txt b/vendor/modules.txt index 1aa9becc1..94ee1ccc4 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -128,7 +128,7 @@ github.com/jbenet/go-context/io github.com/jesseduffield/generics/maps github.com/jesseduffield/generics/set github.com/jesseduffield/generics/slices -# github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4 +# github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d ## explicit; go 1.13 github.com/jesseduffield/go-git/v5 github.com/jesseduffield/go-git/v5/config |