Skip to content

Commit 341018c

Browse files
author
Mario Manno
committed
Fix up git package
Signed-off-by: Guilherme Macedo <[email protected]>
1 parent cc833dd commit 341018c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pkg/git/git.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (g *Git) LsRemote(branch string, commit string) (string, error) {
6868
}
6969

7070
output := &bytes.Buffer{}
71-
if err := g.gitCmd(output, "ls-remote", g.URL, formatRefForBranch(branch)); err != nil {
71+
if err := g.gitCmd(output, "ls-remote", "--", g.URL, formatRefForBranch(branch)); err != nil {
7272
return "", err
7373
}
7474

@@ -97,9 +97,9 @@ func (g *Git) Head(branch string) (string, error) {
9797
// Clone runs git clone with depth 1
9898
func (g *Git) Clone(branch string) error {
9999
if branch == "" {
100-
return g.git("clone", "--depth=1", "-n", g.URL, g.Directory)
100+
return g.git("clone", "--depth=1", "-n", "--", g.URL, g.Directory)
101101
}
102-
return g.git("clone", "--depth=1", "-n", "--branch", branch, g.URL, g.Directory)
102+
return g.git("clone", "--depth=1", "-n", "--branch="+branch, "--", g.URL, g.Directory)
103103
}
104104

105105
// Update updates git repo if remote sha has changed
@@ -302,22 +302,22 @@ func (g *Git) clone(branch string) error {
302302
}
303303

304304
func (g *Git) fetchAndReset(rev string) error {
305-
if err := g.git("-C", g.Directory, "fetch", "origin", rev); err != nil {
305+
if err := g.git("-C", g.Directory, "fetch", "origin", "--", rev); err != nil {
306306
return err
307307
}
308308
return g.reset("FETCH_HEAD")
309309
}
310310

311311
func (g *Git) reset(rev string) error {
312-
return g.git("-C", g.Directory, "reset", "--hard", rev)
312+
return g.git("-C", g.Directory, "reset", "--hard", "--", rev)
313313
}
314314

315315
func (g *Git) currentCommit() (string, error) {
316316
return g.gitOutput("-C", g.Directory, "rev-parse", "HEAD")
317317
}
318318

319319
func (g *Git) gitCmd(output io.Writer, args ...string) error {
320-
kv := fmt.Sprintf("credential.helper=%s", "/bin/sh -c 'echo password=$GIT_PASSWORD'")
320+
kv := fmt.Sprintf("credential.helper=%s", `/bin/sh -c 'echo "password=$GIT_PASSWORD"'`)
321321
cmd := exec.Command("git", append([]string{"-c", kv}, args...)...)
322322
cmd.Env = append(os.Environ(), fmt.Sprintf("GIT_PASSWORD=%s", g.password))
323323
stderrBuf := &bytes.Buffer{}

0 commit comments

Comments
 (0)