@@ -302,6 +302,11 @@ func findRemoteDefaultBranch(ctx context.Context, u *url.URL) string {
302
302
// setupGitEnv sets up the environment for the given command. This is used to
303
303
// pass configuration data to git and ssh and enables advanced cloning methods.
304
304
func setupGitEnv (cmd * exec.Cmd , sshKeyFile string ) {
305
+ // If there's no sshKeyFile argument to deal with, we can skip this
306
+ // entirely.
307
+ if sshKeyFile == "" {
308
+ return
309
+ }
305
310
const gitSSHCommand = "GIT_SSH_COMMAND="
306
311
var sshCmd []string
307
312
@@ -323,14 +328,12 @@ func setupGitEnv(cmd *exec.Cmd, sshKeyFile string) {
323
328
sshCmd = []string {gitSSHCommand + "ssh" }
324
329
}
325
330
326
- if sshKeyFile != "" {
327
- // We have an SSH key temp file configured, tell ssh about this.
328
- if runtime .GOOS == "windows" {
329
- sshKeyFile = strings .Replace (sshKeyFile , `\` , `/` , - 1 )
330
- }
331
- sshCmd = append (sshCmd , "-i" , sshKeyFile )
332
- env = append (env , strings .Join (sshCmd , " " ))
331
+ // We have an SSH key temp file configured, tell ssh about this.
332
+ if runtime .GOOS == "windows" {
333
+ sshKeyFile = strings .Replace (sshKeyFile , `\` , `/` , - 1 )
333
334
}
335
+ sshCmd = append (sshCmd , "-i" , sshKeyFile )
336
+ env = append (env , strings .Join (sshCmd , " " ))
334
337
335
338
cmd .Env = env
336
339
}
0 commit comments