Skip to content

Commit

Permalink
fix(git-sensor): force fetch from git repository
Browse files Browse the repository at this point in the history
We've run into an issue with using the existing git sensor with our repository.  The sensor works for a while until it starts erroring on `failed to fetch. err: some refs were not updated`.  This seems to happen when we merge code to our repository, and our deploy process updates tags.  Updating tags on existing branches causes git to throw an error unless you force fetch.  The artifact already force fetches when given a particular ref, and I can't think of a downside of doing it everywhere given that you wouldn't be making local changes to branches in a sensor.

Signed-off-by: rory.lamendola <[email protected]>
  • Loading branch information
Rory LaMendola authored and whynowy committed Mar 24, 2021
1 parent 5687b59 commit 3a2581d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sensors/artifacts/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func (g *GitArtifactReader) readFromRepository(r *git.Repository, dir string) ([
fetchOptions := &git.FetchOptions{
RemoteName: g.artifact.Remote.Name,
RefSpecs: fetchRefSpec,
Force: true,
}
if auth != nil {
fetchOptions.Auth = auth
Expand All @@ -143,6 +144,7 @@ func (g *GitArtifactReader) readFromRepository(r *git.Repository, dir string) ([
fetchOptions := &git.FetchOptions{
RemoteName: g.getRemote(),
RefSpecs: fetchRefSpec,
Force: true,
}
if auth != nil {
fetchOptions.Auth = auth
Expand Down

0 comments on commit 3a2581d

Please sign in to comment.