From a7e227eac73a8f9cb938f393cbe4331515b89dc1 Mon Sep 17 00:00:00 2001 From: Cooper Oh Date: Mon, 16 Dec 2024 22:24:36 +0900 Subject: [PATCH] to -> onto --- cmd/cherry-pick/main.go | 8 ++++---- git/cherry-pick.go | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cmd/cherry-pick/main.go b/cmd/cherry-pick/main.go index 6838d7e..d8de275 100644 --- a/cmd/cherry-pick/main.go +++ b/cmd/cherry-pick/main.go @@ -9,21 +9,21 @@ import ( ) var ( - prNumber = flag.Int("pr", 0, "The PR number to cherry-pick (required)") - to = flag.String("to", "", "The branch to cherry-pick to (required)") + prNumber = flag.Int("pr", 0, "The PR number onto cherry-pick (required)") + onto = flag.String("onto", "", "The branch to cherry-pick onto (required)") rebase = flag.Bool("rebase", false, "Rebase the cherry-pick") ) func main() { flag.Parse() - if *prNumber == 0 || *to == "" { + if *prNumber == 0 || *onto == "" { flag.Usage() os.Exit(2) } cherryPick := git.CherryPick{ PRNumber: *prNumber, - To: *to, + OnTo: *onto, Rebase: *rebase, } diff --git a/git/cherry-pick.go b/git/cherry-pick.go index 0c3d4eb..51b0e40 100644 --- a/git/cherry-pick.go +++ b/git/cherry-pick.go @@ -15,7 +15,7 @@ import ( type CherryPick struct { PRNumber int - To string + OnTo string Rebase bool } @@ -40,7 +40,7 @@ func (cherryPick *CherryPick) RunWithContext(ctx context.Context) error { } } - var cherryPickBranchName = fmt.Sprintf("cherry-pick-pr-%d-to-%s-%d", cherryPick.PRNumber, cherryPick.To, time.Now().Unix()) + var cherryPickBranchName = fmt.Sprintf("cherry-pick-pr-%d-onto-%s-%d", cherryPick.PRNumber, cherryPick.OnTo, time.Now().Unix()) tui.WithSpinner(ctx, fmt.Sprintf("Fetching PR #%d to branch %s", cherryPick.PRNumber, cherryPickBranchName), func(ctx context.Context) (string, error) { if _, stderr, err := ExecContext(ctx, "git", "fetch", "--recurse-submodules", "origin", fmt.Sprintf("pull/%d/head:%s", cherryPick.PRNumber, cherryPickBranchName)); err != nil { @@ -59,7 +59,7 @@ func (cherryPick *CherryPick) RunWithContext(ctx context.Context) error { }) if cherryPick.Rebase { - tui.WithSpinner(ctx, fmt.Sprintf("Rebasing branch %s onto %s", cherryPickBranchName, cherryPick.To), func(ctx context.Context) (string, error) { + tui.WithSpinner(ctx, fmt.Sprintf("Rebasing branch %s onto %s", cherryPickBranchName, cherryPick.OnTo), func(ctx context.Context) (string, error) { prDiff, stderr, err := gh.ExecContext(ctx, "pr", "diff", strconv.Itoa(cherryPick.PRNumber), "--patch") if err != nil { return "", fmt.Errorf("error getting PR diff: %w: %s", err, stderr.String()) @@ -69,10 +69,10 @@ func (cherryPick *CherryPick) RunWithContext(ctx context.Context) error { return "", fmt.Errorf("error applying PR diff: %w: %s", err, stderr.String()) } - return fmt.Sprintf("Rebased branch %s onto %s", cherryPickBranchName, cherryPick.To), nil + return fmt.Sprintf("Rebased branch %s onto %s", cherryPickBranchName, cherryPick.OnTo), nil }) } else { - tui.WithSpinner(ctx, fmt.Sprintf("Cherry-picking branch %s onto %s", cherryPickBranchName, cherryPick.To), func(ctx context.Context) (string, error) { + tui.WithSpinner(ctx, fmt.Sprintf("Cherry-picking branch %s onto %s", cherryPickBranchName, cherryPick.OnTo), func(ctx context.Context) (string, error) { stdout, stderr, err := ExecContext(ctx, "gh", "pr", "view", strconv.Itoa(cherryPick.PRNumber), "--json", "--mergeCommit", "--jq", ".mergeCommit.oid") if err != nil { return "", fmt.Errorf("error getting PR merge commit: %w: %s", err, stderr.String()) @@ -87,7 +87,7 @@ func (cherryPick *CherryPick) RunWithContext(ctx context.Context) error { return "", fmt.Errorf("error cherry-picking PR merge commit: %w: %s", err, stderr.String()) } - return fmt.Sprintf("Cherry-picked branch %s onto %s", cherryPickBranchName, cherryPick.To), nil + return fmt.Sprintf("Cherry-picked branch %s onto %s", cherryPickBranchName, cherryPick.OnTo), nil }) }