Skip to content

Commit

Permalink
fix: try harder to fetch tags from remote when updating cache
Browse files Browse the repository at this point in the history
Fixes: Issue #155
  • Loading branch information
nisimond authored and retr0h committed Feb 17, 2024
1 parent 24da56e commit b9aa3f4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/go-client/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ require (
github.com/spf13/afero v1.11.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
)
4 changes: 2 additions & 2 deletions examples/go-client/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
2 changes: 1 addition & 1 deletion internal/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (g *Git) Clone(
// Update the repo. Fetch the current HEAD and any new tags that may have
// appeared, and update the cache.
func (g *Git) Update(cloneDir string) error {
return g.execManager.RunCmdInDir("git", []string{"fetch", "--tags"}, cloneDir)
return g.execManager.RunCmdInDir("git", []string{"fetch", "--tags", "--force"}, cloneDir)
}

// Worktree create a working tree from the repo in `cloneDir` at `version` in `dstDir`.
Expand Down
4 changes: 2 additions & 2 deletions internal/git/git_public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (suite *GitManagerPublicTestSuite) TestWorktreeError() {

func (suite *GitManagerPublicTestSuite) TestUpdateOk() {
suite.mockExec.EXPECT().
RunCmdInDir("git", []string{"fetch", "--tags"}, suite.cloneDir).
RunCmdInDir("git", []string{"fetch", "--tags", "--force"}, suite.cloneDir).
Return(nil)
err := suite.gm.Update(suite.cloneDir)
assert.NoError(suite.T(), err)
Expand All @@ -119,7 +119,7 @@ func (suite *GitManagerPublicTestSuite) TestUpdateOk() {
func (suite *GitManagerPublicTestSuite) TestUpdateError() {
errors := errors.New("tests error")
suite.mockExec.EXPECT().
RunCmdInDir("git", []string{"fetch", "--tags"}, suite.cloneDir).
RunCmdInDir("git", []string{"fetch", "--tags", "--force"}, suite.cloneDir).
Return(errors)
err := suite.gm.Update(suite.cloneDir)
assert.Error(suite.T(), err)
Expand Down

0 comments on commit b9aa3f4

Please sign in to comment.