From f2f6fcbb0d10247f08a599a7073feff3acc5e7cd Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Mon, 2 Oct 2023 22:53:49 +0300 Subject: [PATCH] fixup deps Signed-off-by: Vasiliy Tolstov --- cmd/pkgdashcli/main.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cmd/pkgdashcli/main.go b/cmd/pkgdashcli/main.go index ae2cb2f..8034418 100644 --- a/cmd/pkgdashcli/main.go +++ b/cmd/pkgdashcli/main.go @@ -283,11 +283,16 @@ func giteaPullRequest(ctx context.Context, cfg *Config, branch string, mods map[ logger.Fatalf(ctx, "failed to reset repo branch: %v", err) } - newbranch := fmt.Sprintf("pkgdash/go_modules/%s-%s", path, 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, "checkout ref %s to %s", headRef) if err = wtree.Checkout(&git.CheckoutOptions{ Hash: headRef.Hash(), - Branch: newbranch, + Branch: newref.Name(), Create: true, Force: true, }); err != nil { @@ -326,7 +331,7 @@ func giteaPullRequest(ctx context.Context, cfg *Config, branch string, mods map[ } logger.Infof(ctx, "worktree commit") - commit, err := wtree.Commit(wTitle.String(), &git.CommitOptions{ + _, err = wtree.Commit(wTitle.String(), &git.CommitOptions{ Parents: []plumbing.Hash{headRef.Hash()}, Author: &object.Signature{ Name: "gitea-actions", @@ -338,12 +343,6 @@ func giteaPullRequest(ctx context.Context, cfg *Config, branch string, mods map[ logger.Fatalf(ctx, "failed to commit: %v", err) } - newref := plumbing.NewHashReference(plumbing.ReferenceName(fmt.Sprintf("refs/heads/pkgdash/go_modules/%s-%s", path, mod.Version)), commit) - - if err = repo.Storer.SetReference(newref); err != nil { - logger.Fatalf(ctx, "failed to create repo branch: %v", err) - } - refspec := gitconfig.RefSpec(fmt.Sprintf("+" + newref.Name().String() + ":" + newref.Name().String())) logger.Infof(ctx, "try to push %s", refspec)