mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-05 00:59:19 +02:00
Bump go-git
This commit is contained in:
55
vendor/github.com/jesseduffield/go-git/v5/submodule.go
generated
vendored
55
vendor/github.com/jesseduffield/go-git/v5/submodule.go
generated
vendored
@ -5,11 +5,13 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"path"
|
||||
|
||||
"github.com/go-git/go-billy/v5"
|
||||
"github.com/jesseduffield/go-git/v5/config"
|
||||
"github.com/jesseduffield/go-git/v5/plumbing"
|
||||
"github.com/jesseduffield/go-git/v5/plumbing/format/index"
|
||||
"github.com/jesseduffield/go-git/v5/plumbing/transport"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -131,9 +133,29 @@ func (s *Submodule) Repository() (*Repository, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
moduleEndpoint, err := transport.NewEndpoint(s.c.URL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !path.IsAbs(moduleEndpoint.Path) && moduleEndpoint.Protocol == "file" {
|
||||
remotes, err := s.w.r.Remotes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rootEndpoint, err := transport.NewEndpoint(remotes[0].c.URLs[0])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rootEndpoint.Path = path.Join(rootEndpoint.Path, moduleEndpoint.Path)
|
||||
*moduleEndpoint = *rootEndpoint
|
||||
}
|
||||
|
||||
_, err = r.CreateRemote(&config.RemoteConfig{
|
||||
Name: DefaultRemoteName,
|
||||
URLs: []string{s.c.URL},
|
||||
URLs: []string{moduleEndpoint.String()},
|
||||
})
|
||||
|
||||
return r, err
|
||||
@ -151,7 +173,7 @@ func (s *Submodule) Update(o *SubmoduleUpdateOptions) error {
|
||||
// setting in the options SubmoduleUpdateOptions.Init equals true.
|
||||
//
|
||||
// The provided Context must be non-nil. If the context expires before the
|
||||
// operation is complete, an error is returned. The context only affects to the
|
||||
// operation is complete, an error is returned. The context only affects the
|
||||
// transport operations.
|
||||
func (s *Submodule) UpdateContext(ctx context.Context, o *SubmoduleUpdateOptions) error {
|
||||
return s.update(ctx, o, plumbing.ZeroHash)
|
||||
@ -192,10 +214,10 @@ func (s *Submodule) update(ctx context.Context, o *SubmoduleUpdateOptions, force
|
||||
return err
|
||||
}
|
||||
|
||||
return s.doRecursiveUpdate(r, o)
|
||||
return s.doRecursiveUpdate(ctx, r, o)
|
||||
}
|
||||
|
||||
func (s *Submodule) doRecursiveUpdate(r *Repository, o *SubmoduleUpdateOptions) error {
|
||||
func (s *Submodule) doRecursiveUpdate(ctx context.Context, r *Repository, o *SubmoduleUpdateOptions) error {
|
||||
if o.RecurseSubmodules == NoRecurseSubmodules {
|
||||
return nil
|
||||
}
|
||||
@ -214,14 +236,14 @@ func (s *Submodule) doRecursiveUpdate(r *Repository, o *SubmoduleUpdateOptions)
|
||||
*new = *o
|
||||
|
||||
new.RecurseSubmodules--
|
||||
return l.Update(new)
|
||||
return l.UpdateContext(ctx, new)
|
||||
}
|
||||
|
||||
func (s *Submodule) fetchAndCheckout(
|
||||
ctx context.Context, r *Repository, o *SubmoduleUpdateOptions, hash plumbing.Hash,
|
||||
) error {
|
||||
if !o.NoFetch {
|
||||
err := r.FetchContext(ctx, &FetchOptions{Auth: o.Auth})
|
||||
err := r.FetchContext(ctx, &FetchOptions{Auth: o.Auth, Depth: o.Depth})
|
||||
if err != nil && err != NoErrAlreadyUpToDate {
|
||||
return err
|
||||
}
|
||||
@ -232,6 +254,25 @@ func (s *Submodule) fetchAndCheckout(
|
||||
return err
|
||||
}
|
||||
|
||||
// Handle a case when submodule refers to an orphaned commit that's still reachable
|
||||
// through Git server using a special protocol capability[1].
|
||||
//
|
||||
// [1]: https://git-scm.com/docs/protocol-capabilities#_allow_reachable_sha1_in_want
|
||||
if !o.NoFetch {
|
||||
if _, err := w.r.Object(plumbing.AnyObject, hash); err != nil {
|
||||
refSpec := config.RefSpec("+" + hash.String() + ":" + hash.String())
|
||||
|
||||
err := r.FetchContext(ctx, &FetchOptions{
|
||||
Auth: o.Auth,
|
||||
RefSpecs: []config.RefSpec{refSpec},
|
||||
Depth: o.Depth,
|
||||
})
|
||||
if err != nil && err != NoErrAlreadyUpToDate && err != ErrExactSHA1NotSupported {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := w.Checkout(&CheckoutOptions{Hash: hash}); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -262,7 +303,7 @@ func (s Submodules) Update(o *SubmoduleUpdateOptions) error {
|
||||
// UpdateContext updates all the submodules in this list.
|
||||
//
|
||||
// The provided Context must be non-nil. If the context expires before the
|
||||
// operation is complete, an error is returned. The context only affects to the
|
||||
// operation is complete, an error is returned. The context only affects the
|
||||
// transport operations.
|
||||
func (s Submodules) UpdateContext(ctx context.Context, o *SubmoduleUpdateOptions) error {
|
||||
for _, sub := range s {
|
||||
|
Reference in New Issue
Block a user