#8 change checkout.

This commit is contained in:
Gorbunov Kirill Andreevich 2024-04-21 15:26:13 +03:00
parent 8fc16a2e3b
commit 58da3e6d10

View File

@ -145,7 +145,7 @@ func (g *Gitlab) 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 {
@ -455,12 +455,14 @@ func GetPulls(ctx context.Context, url, projectId, branch, password string) ([]*
}
}
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{
Branch: ref.Name(),
Force: true,
Keep: false,
}); err != nil {
logger.Error(ctx, fmt.Sprintf("failed to reset: %v", err))
}