mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-06 03:53:59 +02:00
Merge pull request #2232 from lukaspiatkowski/fix-negative-refspec
fix https://github.com/jesseduffield/go-git/pull/1
This commit is contained in:
commit
3e15315339
2
go.mod
2
go.mod
@ -17,7 +17,7 @@ require (
|
|||||||
github.com/imdario/mergo v0.3.11
|
github.com/imdario/mergo v0.3.11
|
||||||
github.com/integrii/flaggy v1.4.0
|
github.com/integrii/flaggy v1.4.0
|
||||||
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68
|
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68
|
||||||
github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4
|
github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d
|
||||||
github.com/jesseduffield/gocui v0.3.1-0.20221016041636-16c24668f71c
|
github.com/jesseduffield/gocui v0.3.1-0.20221016041636-16c24668f71c
|
||||||
github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10
|
github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10
|
||||||
github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5
|
github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5
|
||||||
|
4
go.sum
4
go.sum
@ -70,8 +70,8 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOl
|
|||||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
|
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
|
||||||
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68 h1:EQP2Tv8TIcC6Y4RI+1ZbJDOHfGJ570tPeYVCqo7/tws=
|
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68 h1:EQP2Tv8TIcC6Y4RI+1ZbJDOHfGJ570tPeYVCqo7/tws=
|
||||||
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68/go.mod h1:+LLj9/WUPAP8LqCchs7P+7X0R98HiFujVFANdNaxhGk=
|
github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68/go.mod h1:+LLj9/WUPAP8LqCchs7P+7X0R98HiFujVFANdNaxhGk=
|
||||||
github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4 h1:GOQrmaE8i+KEdB8NzAegKYd4tPn/inM0I1uo0NXFerg=
|
github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d h1:bO+OmbreIv91rCe8NmscRwhFSqkDJtzWCPV4Y+SQuXE=
|
||||||
github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4/go.mod h1:nGNEErzf+NRznT+N2SWqmHnDnF9aLgANB1CUNEan09o=
|
github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d/go.mod h1:nGNEErzf+NRznT+N2SWqmHnDnF9aLgANB1CUNEan09o=
|
||||||
github.com/jesseduffield/gocui v0.3.1-0.20221016041636-16c24668f71c h1:ttqCvM86hyp4V3DtRPxLo9imD1s+n6ry/zshPx0tt98=
|
github.com/jesseduffield/gocui v0.3.1-0.20221016041636-16c24668f71c h1:ttqCvM86hyp4V3DtRPxLo9imD1s+n6ry/zshPx0tt98=
|
||||||
github.com/jesseduffield/gocui v0.3.1-0.20221016041636-16c24668f71c/go.mod h1:znJuCDnF2Ph40YZSlBwdX/4GEofnIoWLGdT4mK5zRAU=
|
github.com/jesseduffield/gocui v0.3.1-0.20221016041636-16c24668f71c/go.mod h1:znJuCDnF2Ph40YZSlBwdX/4GEofnIoWLGdT4mK5zRAU=
|
||||||
github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 h1:jmpr7KpX2+2GRiE91zTgfq49QvgiqB0nbmlwZ8UnOx0=
|
github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 h1:jmpr7KpX2+2GRiE91zTgfq49QvgiqB0nbmlwZ8UnOx0=
|
||||||
|
27
vendor/github.com/jesseduffield/go-git/v5/config/refspec.go
generated
vendored
27
vendor/github.com/jesseduffield/go-git/v5/config/refspec.go
generated
vendored
@ -11,11 +11,13 @@ const (
|
|||||||
refSpecWildcard = "*"
|
refSpecWildcard = "*"
|
||||||
refSpecForce = "+"
|
refSpecForce = "+"
|
||||||
refSpecSeparator = ":"
|
refSpecSeparator = ":"
|
||||||
|
refSpecNegative = "^"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrRefSpecMalformedSeparator = errors.New("malformed refspec, separators are wrong")
|
ErrRefSpecMalformedSeparator = errors.New("malformed refspec, separators are wrong")
|
||||||
ErrRefSpecMalformedWildcard = errors.New("malformed refspec, mismatched number of wildcards")
|
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.
|
// RefSpec is a mapping from local branches to remote references.
|
||||||
@ -31,6 +33,24 @@ type RefSpec string
|
|||||||
// Validate validates the RefSpec
|
// Validate validates the RefSpec
|
||||||
func (s RefSpec) Validate() error {
|
func (s RefSpec) Validate() error {
|
||||||
spec := string(s)
|
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 {
|
if strings.Count(spec, refSpecSeparator) != 1 {
|
||||||
return ErrRefSpecMalformedSeparator
|
return ErrRefSpecMalformedSeparator
|
||||||
}
|
}
|
||||||
@ -64,12 +84,17 @@ func (s RefSpec) IsExactSHA1() bool {
|
|||||||
return plumbing.IsHash(s.Src())
|
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.
|
// Src return the src side.
|
||||||
func (s RefSpec) Src() string {
|
func (s RefSpec) Src() string {
|
||||||
spec := string(s)
|
spec := string(s)
|
||||||
|
|
||||||
var start int
|
var start int
|
||||||
if s.IsForceUpdate() {
|
if s.IsForceUpdate() || s.IsNegative() {
|
||||||
start = 1
|
start = 1
|
||||||
} else {
|
} else {
|
||||||
start = 0
|
start = 0
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -128,7 +128,7 @@ github.com/jbenet/go-context/io
|
|||||||
github.com/jesseduffield/generics/maps
|
github.com/jesseduffield/generics/maps
|
||||||
github.com/jesseduffield/generics/set
|
github.com/jesseduffield/generics/set
|
||||||
github.com/jesseduffield/generics/slices
|
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
|
## explicit; go 1.13
|
||||||
github.com/jesseduffield/go-git/v5
|
github.com/jesseduffield/go-git/v5
|
||||||
github.com/jesseduffield/go-git/v5/config
|
github.com/jesseduffield/go-git/v5/config
|
||||||
|
Loading…
Reference in New Issue
Block a user