Skip to content

Commit d081119

Browse files
authored
Fix username to git if it is empty. Will document it (#250)
* Fix username to git if it is empty. Will document it * Added note
1 parent 13df0a5 commit d081119

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

workers/pipeline/git.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,13 @@ func getAuthInfo(repo *gaia.GitRepo, callBack gossh.HostKeyCallback) (transport.
310310
}
311311
} else if repo.PrivateKey.Key != "" {
312312
var err error
313-
auth, err = ssh.NewPublicKeys(repo.PrivateKey.Username, []byte(repo.PrivateKey.Key), repo.PrivateKey.Password)
313+
username := repo.PrivateKey.Username
314+
// If the user does not specify git user here this will not work with github which requires it.
315+
// If it's set though, in case of a custom install or any other medium then github, we don't overwrite it.
316+
if username == "" {
317+
username = "git"
318+
}
319+
auth, err = ssh.NewPublicKeys(username, []byte(repo.PrivateKey.Key), repo.PrivateKey.Password)
314320
if err != nil {
315321
return nil, err
316322
}

0 commit comments

Comments
 (0)