Skip to content

Commit

Permalink
fix: use a backwards-compatible command for setting the remote name
Browse files Browse the repository at this point in the history
commit 21f7c3f uses a `git`
invocation that only works on Git 2.39 or newer; replace it with a
more backward-compatible command that should work on older versions
of Git.

Fixes: Issue retr0h#218
  • Loading branch information
nisimond committed Jun 29, 2024
1 parent d94d071 commit 3a54513
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/go-client/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ require (
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/go-playground/validator/v10 v10.22.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.14.0 // indirect
)
8 changes: 4 additions & 4 deletions examples/go-client/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao=
github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
Expand All @@ -29,8 +29,8 @@ golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOM
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.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/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
5 changes: 4 additions & 1 deletion internal/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ func New(
func (g *Git) Clone(gitURL, origin, cloneDir string) error {
_, err := g.execManager.RunCmd(
"git",
[]string{"clone", "--bare", "--filter=blob:none", "--origin", origin, gitURL, cloneDir},
[]string{
"-c", "clone.defaultRemoteName=" + origin,
"clone", "--bare", "--filter=blob:none", gitURL, cloneDir,
},
)
return err
}
Expand Down
5 changes: 4 additions & 1 deletion internal/git/git_public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ func (suite *GitManagerPublicTestSuite) TearDownTest() {

func (suite *GitManagerPublicTestSuite) TestCloneOk() {
suite.mockExec.EXPECT().
RunCmd("git", []string{"clone", "--bare", "--filter=blob:none", "--origin", suite.origin, suite.gitURL, suite.cloneDir}).
RunCmd("git", []string{
"-c", "clone.defaultRemoteName=" + suite.origin,
"clone", "--bare", "--filter=blob:none", suite.gitURL, suite.cloneDir,
}).
Return("", nil)

err := suite.gm.Clone(suite.gitURL, suite.origin, suite.cloneDir)
Expand Down

0 comments on commit 3a54513

Please sign in to comment.