mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 11:41:41 +00:00
feat: poder obtener el usuario de cualquier remoto
This commit is contained in:
parent
52e22a53bf
commit
c176a8a4b4
1 changed files with 11 additions and 5 deletions
|
@ -173,12 +173,18 @@ class Site
|
||||||
def credentials
|
def credentials
|
||||||
return unless File.exist? private_key
|
return unless File.exist? private_key
|
||||||
|
|
||||||
@credentials ||=
|
Rugged::Credentials::SshKey.new username: username_for(origin), publickey: public_key, privatekey: private_key
|
||||||
begin
|
|
||||||
username = parse_url(origin.url)&.user || 'git'
|
|
||||||
|
|
||||||
Rugged::Credentials::SshKey.new username: username, publickey: public_key, privatekey: private_key
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Obtiene el nombre de usuario para el repositorio remoto, por
|
||||||
|
# defecto git
|
||||||
|
#
|
||||||
|
# @param :remote [Rugged::Remote]
|
||||||
|
# @return [String]
|
||||||
|
def username_for(remote)
|
||||||
|
username = parse_url(remote.url)&.user if remote.respond_to? :url
|
||||||
|
|
||||||
|
username || 'git'
|
||||||
end
|
end
|
||||||
|
|
||||||
# @param :url [String]
|
# @param :url [String]
|
||||||
|
|
Loading…
Reference in a new issue