5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-16 12:31: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 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 end
username = parse_url(origin.url)&.user || 'git'
Rugged::Credentials::SshKey.new username: username, publickey: public_key, privatekey: private_key # Obtiene el nombre de usuario para el repositorio remoto, por
end # 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]