5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-19 22:06:21 +00:00

Merge branch 'issue-12919' of https://0xacab.org/sutty/sutty into 17.3.alpine.panel.sutty.nl

This commit is contained in:
Sutty 2023-09-22 16:20:52 +00:00
commit 7bc482d25d

View file

@ -162,27 +162,40 @@ class Site
# Pushea cambios al repositorio remoto
#
# @param :remote [Rugged::Remote]
# @return [Boolean, nil]
def push
origin.push(rugged.head.canonical_name, credentials: credentials)
git_sh("git", "lfs", "push", "origin", default_branch)
def push(remote = origin)
remote.push(rugged.head.canonical_name, credentials: credentials_for(remote))
git_sh('git', 'lfs', 'push', remote.name, default_branch)
end
private
# @deprecated
def credentials
@credentials ||= credentials_for(origin)
end
# Si Sutty tiene una llave privada de tipo ED25519, devuelve las
# credenciales necesarias para trabajar con repositorios remotos.
#
# @param :remote [Rugged::Remote]
# @return [Nil, Rugged::Credentials::SshKey]
def credentials
def credentials_for(remote)
return unless File.exist? private_key
@credentials ||=
begin
username = parse_url(origin.url)&.user || 'git'
Rugged::Credentials::SshKey.new username: username_for(remote), 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]