From 49440122924ec8cd717a2000af1548e5236d1362 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Mon, 2 Oct 2023 23:52:27 +0300 Subject: [PATCH] fixup deps Signed-off-by: Vasiliy Tolstov --- cmd/pkgdashcli/main.go | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/cmd/pkgdashcli/main.go b/cmd/pkgdashcli/main.go index 8034418..8120038 100644 --- a/cmd/pkgdashcli/main.go +++ b/cmd/pkgdashcli/main.go @@ -71,6 +71,10 @@ func main() { ctx, cancel := context.WithCancel(context.Background()) defer cancel() + if err = logger.DefaultLogger.Init(logger.WithCallerSkipCount(3)); err != nil { + logger.Errorf(ctx, "logger init error: %v", err) + } + cfg := &Config{} if err = config.Load(ctx, @@ -283,20 +287,14 @@ func giteaPullRequest(ctx context.Context, cfg *Config, branch string, mods map[ logger.Fatalf(ctx, "failed to reset repo branch: %v", err) } - 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) + logger.Infof(ctx, "checkout ref %s", headRef) if err = wtree.Checkout(&git.CheckoutOptions{ Hash: headRef.Hash(), - Branch: newref.Name(), + Branch: plumbing.NewBranchReferenceName(fmt.Sprintf("pkgdash/go_modules/%s-%s", path, mod.Version)), Create: true, Force: true, }); err != nil { - logger.Fatalf(ctx, "failed to get checkout tree: %v", err) + logger.Fatalf(ctx, "failed to checkout tree: %v", err) } epath, err := exec.LookPath("go") @@ -343,8 +341,17 @@ func giteaPullRequest(ctx context.Context, cfg *Config, branch string, mods map[ logger.Fatalf(ctx, "failed to commit: %v", err) } - refspec := gitconfig.RefSpec(fmt.Sprintf("+" + newref.Name().String() + ":" + newref.Name().String())) - logger.Infof(ctx, "try to push %s", refspec) + 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) + } + */ + + refspec := gitconfig.RefSpec(fmt.Sprintf("+refs/heads/pkgdash/go_modules/%s-%s:refs/heads/pkgdash/go_modules/%s-%s", path, mod.Version, path, mod.Version)) + + logger.Infof(ctx, "try to push refspec %s", refspec) if err = repo.PushContext(ctx, &git.PushOptions{ RefSpecs: []gitconfig.RefSpec{refspec},