MergeWithStrategy merge a branch into the current branch using the specified strategy.
(path, branch, strategy string)
| 68 | |
| 69 | // MergeWithStrategy merge a branch into the current branch using the specified strategy. |
| 70 | func MergeWithStrategy(path, branch, strategy string) error { |
| 71 | var args []string |
| 72 | switch strategy { |
| 73 | case "theirs": |
| 74 | args = []string{"merge", "-X", "theirs", branch} |
| 75 | case "ours": |
| 76 | args = []string{"merge", "-X", "ours", branch} |
| 77 | case "": |
| 78 | args = []string{"merge", branch} |
| 79 | default: |
| 80 | return fmt.Errorf("internal error: unsupported merge strategy: %s", strategy) |
| 81 | } |
| 82 | |
| 83 | _, err := Run(context.Background(), path, args...) |
| 84 | if err != nil { |
| 85 | return err |
| 86 | } |
| 87 | return nil |
| 88 | } |
| 89 | |
| 90 | // MergeWithBailOnConflict attempts to merge a branch into the current branch and aborts if there are conflicts. |
| 91 | // Returns true if merge was successful, false if there were conflicts (but abort succeeded). |