diff --git a/cmd/spr/main.go b/cmd/spr/main.go index fc03ce5..dece605 100644 --- a/cmd/spr/main.go +++ b/cmd/spr/main.go @@ -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") @@ -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"}, + }, }, }, { diff --git a/config/config.go b/config/config.go index 3e34792..10b7f9d 100644 --- a/config/config.go +++ b/config/config.go @@ -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"` diff --git a/git/mockgit/mockgit.go b/git/mockgit/mockgit.go index 1316d07..da879d4 100644 --- a/git/mockgit/mockgit.go +++ b/git/mockgit/mockgit.go @@ -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)) } diff --git a/git/realgit/realcmd.go b/git/realgit/realcmd.go index 5bae153..7963790 100644 --- a/git/realgit/realcmd.go +++ b/git/realgit/realcmd.go @@ -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