5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-16 09:21:42 +00:00

feat: poder obtener el usuario de cualquier remoto

This commit is contained in:
f 2023-09-22 13:19:21 -03:00
parent 52e22a53bf
commit c176a8a4b4
No known key found for this signature in database

View file

@ -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, publickey: public_key, privatekey: private_key
Rugged::Credentials::SshKey.new username: username_for(origin), 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]