From 3a2581dc41fd1e49bf0f5b2d985800161a4aa4fb Mon Sep 17 00:00:00 2001 From: Rory LaMendola Date: Wed, 24 Mar 2021 11:13:42 -0600 Subject: [PATCH] fix(git-sensor): force fetch from git repository 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 --- sensors/artifacts/git.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sensors/artifacts/git.go b/sensors/artifacts/git.go index dbbf99e800..0ad8be32b8 100644 --- a/sensors/artifacts/git.go +++ b/sensors/artifacts/git.go @@ -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 @@ -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