feat(commands/mr/create): rebase if tracking branch already set

This commit is contained in:
Leo 2020-12-28 02:41:55 -03:00
parent 1ac2f628a6
commit 968cc868f7
1 changed files with 10 additions and 0 deletions

View File

@ -254,6 +254,16 @@ func createRun(opts *CreateOpts) error {
}
if opts.Autofill {
branchConfig := git.ReadBranchConfig(opts.SourceBranch)
// If there is branch information then rebase it before pushing
if branchConfig.RemoteName != "" && (branchConfig.MergeRef != "" || branchConfig.RemoteURL != nil) {
err := git.Rebase(opts.IO.StdOut, opts.IO.StdErr)
if err != nil {
return fmt.Errorf("rebase failed: %s", err)
}
}
if err = mrBodyAndTitle(opts); err != nil {
return err
}