mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-19 19:16:22 +00:00
Merge branch 'issue-12919' of https://0xacab.org/sutty/sutty into 17.3.alpine.panel.sutty.nl
This commit is contained in:
commit
7bc482d25d
1 changed files with 22 additions and 9 deletions
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue