6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-04 23:14:43 +00:00

Add ssh key authentication when cloning via ssh

This commit is contained in:
Grzegorz Dlugoszewski
2020-06-04 15:45:46 +02:00
parent f4636a3a73
commit 239ff699a3
5 changed files with 209 additions and 7 deletions

View File

@@ -16,6 +16,8 @@ const (
DefReposRoot = "repositories"
KeyDefaultHost = "defaultHost"
DefDefaultHost = "github.com"
KeyPrivateKey = "privateKey"
DefPrivateKey = "id_rsa"
)
// gitconfig provides methods for looking up configiration values inside .gitconfig file
@@ -56,6 +58,10 @@ func setMissingValues(cfg *gitconfig) {
if isUnsetOrEmpty(KeyDefaultHost) {
viper.Set(KeyDefaultHost, cfg.get(KeyDefaultHost, DefDefaultHost))
}
if isUnsetOrEmpty(KeyPrivateKey) {
viper.Set(KeyPrivateKey, cfg.get(KeyPrivateKey, path.Join(home(), ".ssh", DefPrivateKey)))
}
}
// get looks up the value for a given key in gitconfig file.