···2727 return nil
2828}
29293030+func (g *GitRepo) Sync(branch string) error {
3131+ fetchOpts := &git.FetchOptions{
3232+ RefSpecs: []config.RefSpec{
3333+ config.RefSpec(fmt.Sprintf("+refs/heads/%s:refs/heads/%s", branch, branch)),
3434+ },
3535+ }
3636+3737+ err := g.r.Fetch(fetchOpts)
3838+ if errors.Is(git.NoErrAlreadyUpToDate, err) {
3939+ return nil
4040+ } else if err != nil {
4141+ return fmt.Errorf("failed to fetch origin branch: %s: %w", branch, err)
4242+ }
4343+ return nil
4444+}
4545+3046// TrackHiddenRemoteRef tracks a hidden remote in the repository. For example,
3147// if the feature branch on the fork (forkRef) is feature-1, and the remoteRef,
3248// i.e. the branch we want to merge into, is main, this will result in a refspec: