| 162 | } |
| 163 | |
| 164 | func RunUpstreamMerge(ctx context.Context, remote, path, branch string, favourLocal bool) error { |
| 165 | var args []string |
| 166 | if favourLocal { |
| 167 | args = []string{"-C", path, "merge", "-X", "ours", fmt.Sprintf("%s/%s", remote, branch)} |
| 168 | } else { |
| 169 | args = []string{"-C", path, "merge", fmt.Sprintf("%s/%s", remote, branch)} |
| 170 | } |
| 171 | cmd := exec.CommandContext(ctx, "git", args...) |
| 172 | if out, err := cmd.CombinedOutput(); err != nil { |
| 173 | var execErr *exec.ExitError |
| 174 | if errors.As(err, &execErr) { |
| 175 | return fmt.Errorf("git merge failed: %s(%s)", string(out), string(execErr.Stderr)) |
| 176 | } |
| 177 | return fmt.Errorf("git merge failed: %w", err) |
| 178 | } |
| 179 | return nil |
| 180 | } |
| 181 | |
| 182 | func RunGitPush(ctx context.Context, path, remoteName, branchName string) error { |
| 183 | cmd := exec.CommandContext(ctx, "git", "-C", path, "push", remoteName, branchName) |