| 89 | } |
| 90 | |
| 91 | func RunGitFetch(ctx context.Context, path, remote string) error { |
| 92 | args := []string{"-C", path, "fetch"} |
| 93 | if remote != "" { |
| 94 | // if remote is specified, fetch from that remote |
| 95 | args = append(args, remote) |
| 96 | } |
| 97 | cmd := exec.CommandContext(ctx, "git", args...) |
| 98 | _, err := cmd.Output() |
| 99 | if err != nil { |
| 100 | var execErr *exec.ExitError |
| 101 | if errors.As(err, &execErr) { |
| 102 | return fmt.Errorf("git fetch failed: %s", string(execErr.Stderr)) |
| 103 | } |
| 104 | return err |
| 105 | } |
| 106 | return nil |
| 107 | } |
| 108 | |
| 109 | // RunGitPull runs a git pull command in the specified path. |
| 110 | func RunGitPull(ctx context.Context, path string, discardLocal bool, remote, remoteName string) (string, error) { |