@@ -68,7 +68,7 @@ func (g *Git) LsRemote(branch string, commit string) (string, error) {
68
68
}
69
69
70
70
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 {
72
72
return "" , err
73
73
}
74
74
@@ -96,7 +96,10 @@ func (g *Git) Head(branch string) (string, error) {
96
96
97
97
// Clone runs git clone with depth 1
98
98
func (g * Git ) Clone (branch string ) error {
99
- return g .git ("clone" , "--depth=1" , "-n" , "--branch" , branch , g .URL , g .Directory )
99
+ if branch == "" {
100
+ return g .git ("clone" , "--depth=1" , "-n" , "--" , g .URL , g .Directory )
101
+ }
102
+ return g .git ("clone" , "--depth=1" , "-n" , "--branch=" + branch , "--" , g .URL , g .Directory )
100
103
}
101
104
102
105
// Update updates git repo if remote sha has changed
@@ -299,22 +302,22 @@ func (g *Git) clone(branch string) error {
299
302
}
300
303
301
304
func (g * Git ) fetchAndReset (rev string ) error {
302
- 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 {
303
306
return err
304
307
}
305
308
return g .reset ("FETCH_HEAD" )
306
309
}
307
310
308
311
func (g * Git ) reset (rev string ) error {
309
- return g .git ("-C" , g .Directory , "reset" , "--hard" , rev )
312
+ return g .git ("-C" , g .Directory , "reset" , "--hard" , "--" , rev )
310
313
}
311
314
312
315
func (g * Git ) currentCommit () (string , error ) {
313
316
return g .gitOutput ("-C" , g .Directory , "rev-parse" , "HEAD" )
314
317
}
315
318
316
319
func (g * Git ) gitCmd (output io.Writer , args ... string ) error {
317
- 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"'` )
318
321
cmd := exec .Command ("git" , append ([]string {"-c" , kv }, args ... )... )
319
322
cmd .Env = append (os .Environ (), fmt .Sprintf ("GIT_PASSWORD=%s" , g .password ))
320
323
stderrBuf := & bytes.Buffer {}
0 commit comments