#8 Checkout, auth. #16

Closed
kgorbunov wants to merge 104 commits from kgorbunov/pkgdash:dev into master
Showing only changes of commit 58da3e6d10 - Show all commits

View File

@ -145,7 +145,7 @@ func (g *Gitlab) RequestOpen(ctx context.Context, branch string, path string, mo
if err != nil { if err != nil {
logger.Fatal(ctx, fmt.Sprintf("failed to get worktree: %v", err)) 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) g.pulls, err = GetPulls(ctx, g.URL, g.Owner, g.Repository, g.Password)
if err != nil { 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() ctx := context.Background()
logger.Debug(ctx, fmt.Sprintf("Checkout: %s", ref.Name().Short())) logger.Debug(ctx, fmt.Sprintf("Checkout: %s", ref.Name().Short()))
if err := w.Checkout(&git.CheckoutOptions{ if err := w.Checkout(&git.CheckoutOptions{
Branch: ref.Name(), Branch: ref.Name(),
Force: true,
Keep: false,
}); err != nil { }); err != nil {
logger.Error(ctx, fmt.Sprintf("failed to reset: %v", err)) logger.Error(ctx, fmt.Sprintf("failed to reset: %v", err))
} }