From 8d989c5f7d4e84fb1cb448c120c97082c1828088 Mon Sep 17 00:00:00 2001 From: Norwin Roosen Date: Sat, 26 Sep 2020 16:03:25 +0200 Subject: [PATCH 1/2] fix TrimLeft bug, improve logging --- cmd/pulls.go | 4 ++-- modules/git/branch.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/pulls.go b/cmd/pulls.go index f10954f..596ca4f 100644 --- a/cmd/pulls.go +++ b/cmd/pulls.go @@ -374,7 +374,7 @@ func runPullsCreate(ctx *cli.Context) error { remote, err := localRepo.TeaFindBranchRemote("", sha) if err != nil { - return err + log.Fatal("could not determine remote for current branch: ", err) } if remote == nil { @@ -422,7 +422,7 @@ func runPullsCreate(ctx *cli.Context) error { }) if err != nil { - log.Fatal("could not create PR: ", err) + log.Fatalf("could not create PR from %s to %s:%s: %s", head, ownerArg, base, err) } in := fmt.Sprintf("# #%d %s (%s)\n%s created %s\n\n%s\n", pr.Index, diff --git a/modules/git/branch.go b/modules/git/branch.go index 042a18b..7773843 100644 --- a/modules/git/branch.go +++ b/modules/git/branch.go @@ -229,5 +229,5 @@ func (r TeaRepo) TeaGetCurrentBranchName() (string, error) { return "", fmt.Errorf("active ref is no branch") } - return strings.TrimLeft(localHead.Name().String(), "refs/heads/"), nil + return strings.TrimPrefix(localHead.Name().String(), "refs/heads/"), nil } -- 2.40.1 From d0605f7c2d28f26b50aba1331ade9866ab31361c Mon Sep 17 00:00:00 2001 From: Norwin Roosen Date: Sat, 26 Sep 2020 16:14:30 +0200 Subject: [PATCH 2/2] small refactor --- cmd/pulls.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/pulls.go b/cmd/pulls.go index 596ca4f..33ca227 100644 --- a/cmd/pulls.go +++ b/cmd/pulls.go @@ -339,7 +339,7 @@ func runPullsCreate(ctx *cli.Context) error { login, ownerArg, repoArg := initCommand() client := login.Client() - repo, _, err := login.Client().GetRepo(ownerArg, repoArg) + repo, _, err := client.GetRepo(ownerArg, repoArg) if err != nil { log.Fatal("could not fetch repo meta: ", err) } @@ -436,7 +436,7 @@ func runPullsCreate(ctx *cli.Context) error { fmt.Print(out) fmt.Println(pr.HTMLURL) - return nil + return err } func argToIndex(arg string) (int64, error) { -- 2.40.1