#8 fix checkout.
This commit is contained in:
parent
cb209a6a7a
commit
a5d39c23f8
@ -149,7 +149,7 @@ func (g *Gitea) RequestOpen(ctx context.Context, branch string, path string, mod
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, fmt.Sprintf("failed to get worktree: %v", err))
|
||||
}
|
||||
defer checkout(wtree, *g.baseRef)
|
||||
defer checkout(*wtree, *g.baseRef)
|
||||
|
||||
g.pulls, err = GetPulls(ctx, g.URL, g.Owner, g.Repository, g.Password)
|
||||
if err != nil {
|
||||
@ -473,11 +473,16 @@ func GetPulls(ctx context.Context, url, owner, repo, password string) ([]*giteaP
|
||||
return pullsAll, nil
|
||||
}
|
||||
|
||||
func checkout(w *git.Worktree, ref plumbing.Reference) {
|
||||
func checkout(w git.Worktree, ref plumbing.Reference) {
|
||||
ctx := context.Background()
|
||||
logger.Debug(ctx, fmt.Sprintf("Checkout: %s", ref.Name().Short()))
|
||||
|
||||
if err := w.Checkout(&git.CheckoutOptions{Hash: ref.Hash()}); err != nil {
|
||||
logger.Fatal(ctx, fmt.Sprintf("failed to reset: %v", err))
|
||||
if err := w.Checkout(&git.CheckoutOptions{
|
||||
Branch: ref.Name(),
|
||||
Create: false,
|
||||
Force: true,
|
||||
Keep: false,
|
||||
}); err != nil {
|
||||
logger.Error(ctx, fmt.Sprintf("failed to reset: %v", err))
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ func (g *Github) RequestOpen(ctx context.Context, branch string, path string, mo
|
||||
if err != nil {
|
||||
logger.Fatal(ctx, fmt.Sprintf("failed to get worktree: %v", err))
|
||||
}
|
||||
defer checkout(wtree, *g.baseRef)
|
||||
defer checkout(*wtree, *g.baseRef)
|
||||
|
||||
g.pulls, err = GetPulls(ctx, g.URL, g.Owner, g.Repository, g.Password)
|
||||
if err != nil {
|
||||
@ -376,11 +376,16 @@ func GetPulls(ctx context.Context, url, owner, repo, password string) ([]*github
|
||||
return pullsAll, nil
|
||||
}
|
||||
|
||||
func checkout(w *git.Worktree, ref plumbing.Reference) {
|
||||
func checkout(w git.Worktree, ref plumbing.Reference) {
|
||||
ctx := context.Background()
|
||||
logger.Debug(ctx, fmt.Sprintf("Checkout: %s", ref.Name().Short()))
|
||||
|
||||
if err := w.Checkout(&git.CheckoutOptions{Hash: ref.Hash()}); err != nil {
|
||||
logger.Fatal(ctx, fmt.Sprintf("failed to reset: %v", err))
|
||||
if err := w.Checkout(&git.CheckoutOptions{
|
||||
Branch: ref.Name(),
|
||||
Create: false,
|
||||
Force: true,
|
||||
Keep: false,
|
||||
}); err != nil {
|
||||
logger.Error(ctx, fmt.Sprintf("failed to reset: %v", err))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user