Skip to content
Open
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
16 changes: 8 additions & 8 deletions cmd/commands/pr/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,14 @@ func Add(prCmd *cobra.Command, globalOpts *options.GlobalOptions) {
cmdQueue = append(cmdQueue, []string{"git", "fetch", remoteName, pr.Destination.Branch.Name})
if Method == MethodOptionRebase {
cmdQueue = append(cmdQueue, []string{"git", "rebase", remoteDestinationBranch})
if Push {
cmdQueue = append(cmdQueue, []string{"git", "push", "--force-with-lease"})
}
} else {
cmdQueue = append(cmdQueue, []string{"git", "merge", "--commit", remoteDestinationBranch})
if Push {
cmdQueue = append(cmdQueue, []string{"git", "push"})
}
}

var builder strings.Builder
Expand All @@ -124,18 +130,11 @@ func Add(prCmd *cobra.Command, globalOpts *options.GlobalOptions) {
return
}

if Push {
cmdQueue = [][]string{{"git", "push"}}
err = processCmdQueue(cmdQueue)
if err != nil {
logging.Error(err)
}
}
},
}

syncCmd.Flags().StringVar(&Method, "method", "merge", "sync using merge or rebase (merge/rebase)")
syncCmd.Flags().BoolVar(&Push, "push", true, "push after merge/rebase")
syncCmd.Flags().BoolVar(&Push, "push", true, "push after merge/push --force-with-lease after rebase")

prCmd.AddCommand(syncCmd)
}
Expand All @@ -147,6 +146,7 @@ func processCmdQueue(cmdQueue [][]string) error {
if err != nil {
return err
}
logging.Note(strings.Join(args, " "))
cmd := exec.Command(exe, args[1:]...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand Down