syncBranchCmds syncs a branch to ref: a hard reset when force is set, otherwise a fast-forward-only merge. A non-empty path runs the commands there.
(path, ref string, force bool)
| 414 | // syncBranchCmds syncs a branch to ref: a hard reset when force is set, |
| 415 | // otherwise a fast-forward-only merge. A non-empty path runs the commands there. |
| 416 | func syncBranchCmds(path, ref string, force bool) [][]string { |
| 417 | var prefix []string |
| 418 | if path != "" { |
| 419 | prefix = []string{"-C", path} |
| 420 | } |
| 421 | if force { |
| 422 | return [][]string{append(prefix, "reset", "--hard", ref)} |
| 423 | } |
| 424 | // TODO: check if non-fast-forward and suggest to use `--force` |
| 425 | return [][]string{append(prefix, "merge", "--ff-only", ref)} |
| 426 | } |
| 427 | |
| 428 | func worktreeCheckoutCmds(path, branch, ref string, force bool) [][]string { |
| 429 | cmds := [][]string{{"-C", path, "checkout", branch}} |
no outgoing calls
no test coverage detected