Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor no-rebase logic to not use env var kludge #432

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions cmd/spr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,14 @@ VERSION: fork of {{.Version}}
Name: "update",
Aliases: []string{"u", "up"},
Usage: "Update and create pull requests for updated commits in the stack",
Action: func(c *cli.Context) error {
if c.Bool("no-rebase") {
os.Setenv("SPR_NOREBASE", "true")
Before: func(c *cli.Context) error {
// only override whatever was set in yaml if flag is explicitly present
if c.IsSet("no-rebase") {
cfg.User.NoRebase = c.Bool("no-rebase")
}
return nil
},
Action: func(c *cli.Context) error {
if c.IsSet("count") {
count := c.Uint("count")
stackedpr.UpdatePullRequests(ctx, c.StringSlice("reviewer"), &count)
Expand All @@ -178,6 +182,9 @@ VERSION: fork of {{.Version}}
Name: "no-rebase",
Aliases: []string{"nr"},
Usage: "Disable rebasing",
// this env var is needed as previous versions used the env var itself to pass intent to logic
// layer ops so it is likely relied on as a feature by users at this point
EnvVars: []string{"SPR_NOREBASE"},
},
},
},
Expand Down
3 changes: 1 addition & 2 deletions git/realgit/realcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ func (c *gitcmd) GitWithEditor(argStr string, output *string, editorCmd string)
// if output is not nil it will be set to the output of the command

// Rebase disabled
_, noRebaseFlag := os.LookupEnv("SPR_NOREBASE")
if (c.config.User.NoRebase || noRebaseFlag) && strings.HasPrefix(argStr, "rebase") {
if (c.config.User.NoRebase) && strings.HasPrefix(argStr, "rebase") {
return nil
}

Expand Down