Skip to content

Commit

Permalink
Fix git amend to use configured upstream
Browse files Browse the repository at this point in the history
fixes #222

commit-id:470862d8
  • Loading branch information
ejoffe authored and Eitan Joffe committed Mar 30, 2022
1 parent 7e024f7 commit 749b443
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 6 additions & 1 deletion cmd/amend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ var (

// command line opts
type opts struct {
Version bool `short:"v" long:"version" description:"Show version info."`
Debug bool `short:"d" long:"debug" description:"Show verbose debug info."`
Version bool `short:"v" long:"version" description:"Show version."`
}

func init() {
Expand All @@ -39,6 +40,10 @@ func main() {
os.Exit(0)
}

if opts.Debug {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}

gitcmd := realgit.NewGitCmd(config.DefaultConfig())
// check that we are inside a git dir
var output string
Expand Down
2 changes: 1 addition & 1 deletion git/mockgit/mockgit.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (m *Mock) ExpectRemote(remote string) {

func (m *Mock) ExpectFixup(commitHash string) {
m.expect("git commit --fixup " + commitHash)
m.expect("git rebase -i --autosquash --autostash")
m.expect("git rebase -i --autosquash --autostash origin/master")
}

func (m *Mock) expect(cmd string, args ...interface{}) *Mock {
Expand Down
5 changes: 4 additions & 1 deletion spr/spr.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ func (sd *stackediff) AmendCommit(ctx context.Context) {
commitIndex = commitIndex - 1
check(err)
sd.mustgit("commit --fixup "+localCommits[commitIndex].CommitHash, nil)
sd.mustgit("rebase -i --autosquash --autostash", nil)

rebaseCmd := fmt.Sprintf("rebase -i --autosquash --autostash %s/%s",
sd.config.Repo.GitHubRemote, sd.config.Repo.GitHubBranch)
sd.mustgit(rebaseCmd, nil)
}

func (sd *stackediff) addReviewers(ctx context.Context,
Expand Down

0 comments on commit 749b443

Please sign in to comment.