From 79e4051c74dd004591cc6866a3ada5bca8c1dd8a Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Mon, 2 Oct 2023 02:04:45 +0300 Subject: [PATCH] fixup deps Signed-off-by: Vasiliy Tolstov --- cmd/pkgdashcli/main.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/pkgdashcli/main.go b/cmd/pkgdashcli/main.go index b80b765..271ce71 100644 --- a/cmd/pkgdashcli/main.go +++ b/cmd/pkgdashcli/main.go @@ -210,10 +210,12 @@ func giteaPullRequest(ctx context.Context, cfg *Config, mods map[string]modules. if err != nil { logger.Fatalf(ctx, "failed to open repo: %v", err) } + headRef, err := repo.Head() if err != nil { logger.Fatalf(ctx, "failed to get repo head: %v", err) } + wtree, err := repo.Worktree() if err != nil { logger.Fatalf(ctx, "failed to get worktree: %v", err) @@ -223,20 +225,21 @@ func giteaPullRequest(ctx context.Context, cfg *Config, mods map[string]modules. wTitle.Reset() wBody.Reset() - fmt.Printf("%s from %s to %s\n", path, mod.Module.Version, mod.Version) + fmt.Printf("update %s from %s to %s\n", path, mod.Module.Version, mod.Version) newref := plumbing.NewHashReference(plumbing.ReferenceName(fmt.Sprintf("refs/heads/pkgdash/go_modules/%s-%s", path, mod.Version)), headRef.Hash()) if err = repo.Storer.SetReference(newref); err != nil { logger.Fatalf(ctx, "failed to create repo branch: %v", err) } + logger.Infof(ctx, "reset worktree") if err = wtree.Reset(&git.ResetOptions{}); err != nil { logger.Fatalf(ctx, "failed to reset repo branch: %v", err) } - logger.Infof(ctx, "checkout branch %s", envBaseBranch) + logger.Infof(ctx, "checkout ref %s", headRef) if err = wtree.Checkout(&git.CheckoutOptions{ - Branch: plumbing.NewBranchReferenceName(envBaseBranch), + Hash: headRef.Hash(), Create: false, Force: true, }); err != nil {