From 58da3e6d1015aebe20c623a80e6d22d60fd7cacf Mon Sep 17 00:00:00 2001 From: Gorbunov Kirill Andreevich Date: Sun, 21 Apr 2024 15:26:13 +0300 Subject: [PATCH] #8 change checkout. --- internal/source/gitlab/gitlab.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/source/gitlab/gitlab.go b/internal/source/gitlab/gitlab.go index 64aabdf..abf8ef7 100644 --- a/internal/source/gitlab/gitlab.go +++ b/internal/source/gitlab/gitlab.go @@ -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)) }