#8 change checkout.
This commit is contained in:
parent
8fc16a2e3b
commit
58da3e6d10
@ -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))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user