mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 10:01: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
|
||||
return unless File.exist? private_key
|
||||
|
||||
@credentials ||=
|
||||
begin
|
||||
username = parse_url(origin.url)&.user || 'git'
|
||||
Rugged::Credentials::SshKey.new username: username_for(origin), publickey: public_key, privatekey: private_key
|
||||
end
|
||||
|
||||
Rugged::Credentials::SshKey.new username: username, publickey: public_key, privatekey: private_key
|
||||
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
|
||||
|
||||
# @param :url [String]
|
||||
|
|
Loading…
Reference in a new issue