forked from tangled.org/core
this repo has no description

knotserver: fork: add function to sync fork

authored by brookjeynes.dev and committed by Tangled f2d25d31 b73f5cec

Changed files
+16
knotserver
git
+16
knotserver/git/fork.go
··· 27 27 return nil 28 28 } 29 29 30 + func (g *GitRepo) Sync(branch string) error { 31 + fetchOpts := &git.FetchOptions{ 32 + RefSpecs: []config.RefSpec{ 33 + config.RefSpec(fmt.Sprintf("+refs/heads/%s:refs/heads/%s", branch, branch)), 34 + }, 35 + } 36 + 37 + err := g.r.Fetch(fetchOpts) 38 + if errors.Is(git.NoErrAlreadyUpToDate, err) { 39 + return nil 40 + } else if err != nil { 41 + return fmt.Errorf("failed to fetch origin branch: %s: %w", branch, err) 42 + } 43 + return nil 44 + } 45 + 30 46 // TrackHiddenRemoteRef tracks a hidden remote in the repository. For example, 31 47 // if the feature branch on the fork (forkRef) is feature-1, and the remoteRef, 32 48 // i.e. the branch we want to merge into, is main, this will result in a refspec: