Skip to content
Closed
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
39 changes: 24 additions & 15 deletions cmd/spr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,16 @@ VERSION: fork of {{.Version}}
Name: "update",
Aliases: []string{"u", "up"},
Usage: "Update and create pull requests for updated commits in the stack",
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
},
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")
}
if c.IsSet("no-fetch") {
cfg.User.NoFetch = c.Bool("no-fetch")
}
return nil
},
Action: func(c *cli.Context) error {
if c.IsSet("count") {
count := c.Uint("count")
Expand All @@ -218,14 +221,20 @@ VERSION: fork of {{.Version}}
Aliases: []string{"c"},
Usage: "Update a specified number of pull requests from the bottom of the stack",
},
&cli.BoolFlag{
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"},
},
&cli.BoolFlag{
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"},
},
&cli.BoolFlag{
Name: "no-fetch",
Aliases: []string{"nf"},
Usage: "Disable fetch",
EnvVars: []string{"SPR_NOFETCH"},
},
},
},
{
Expand Down
7 changes: 4 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ type UserConfig struct {
StatusBitsHeader bool `default:"true" yaml:"statusBitsHeader"`
StatusBitsEmojis bool `default:"true" yaml:"statusBitsEmojis"`

CreateDraftPRs bool `default:"false" yaml:"createDraftPRs"`
PreserveTitleAndBody bool `default:"false" yaml:"preserveTitleAndBody"`
NoRebase bool `default:"false" yaml:"noRebase"`
CreateDraftPRs bool `default:"false" yaml:"createDraftPRs"`
PreserveTitleAndBody bool `default:"false" yaml:"preserveTitleAndBody"`
NoRebase bool `default:"false" yaml:"noRebase"`
NoFetch bool `default:"false" yaml:"noFetch"`
DeleteMergedBranches bool `default:"false" yaml:"deleteMergedBranches"`
ShortPRLink bool `default:"false" yaml:"shortPRLink"`
ShowCommitID bool `default:"false" yaml:"showCommitID"`
Expand Down
4 changes: 4 additions & 0 deletions git/mockgit/mockgit.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ func (m *Mock) ExpectFetch() {
m.expect("git rebase origin/master --autostash")
}

func (m *Mock) ExpectNoFetch() {
m.expect("git rebase origin/master --autostash")
}

func (m *Mock) ExpectDeleteBranch(branchName string) {
m.expect(fmt.Sprintf("git DeleteRemoteBranch(%s)", branchName))
}
Expand Down
5 changes: 5 additions & 0 deletions git/realgit/realcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ func (c *gitcmd) GitWithEditor(argStr string, output *string, editorCmd string)
// runs a git command
// if output is not nil it will be set to the output of the command

// Fetch disabled
if c.config.User.NoFetch && strings.HasPrefix(argStr, "fetch") {
return nil
}

// Rebase disabled
if (c.config.User.NoRebase) && strings.HasPrefix(argStr, "rebase") {
return nil
Expand Down
Loading