mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-19 22:16: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:
commit
7bc482d25d
1 changed files with 22 additions and 9 deletions
|
@ -162,27 +162,40 @@ class Site
|
||||||
|
|
||||||
# Pushea cambios al repositorio remoto
|
# Pushea cambios al repositorio remoto
|
||||||
#
|
#
|
||||||
|
# @param :remote [Rugged::Remote]
|
||||||
# @return [Boolean, nil]
|
# @return [Boolean, nil]
|
||||||
def push
|
def push(remote = origin)
|
||||||
origin.push(rugged.head.canonical_name, credentials: credentials)
|
remote.push(rugged.head.canonical_name, credentials: credentials_for(remote))
|
||||||
git_sh("git", "lfs", "push", "origin", default_branch)
|
git_sh('git', 'lfs', 'push', remote.name, default_branch)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# @deprecated
|
||||||
|
def credentials
|
||||||
|
@credentials ||= credentials_for(origin)
|
||||||
|
end
|
||||||
|
|
||||||
# Si Sutty tiene una llave privada de tipo ED25519, devuelve las
|
# Si Sutty tiene una llave privada de tipo ED25519, devuelve las
|
||||||
# credenciales necesarias para trabajar con repositorios remotos.
|
# credenciales necesarias para trabajar con repositorios remotos.
|
||||||
#
|
#
|
||||||
|
# @param :remote [Rugged::Remote]
|
||||||
# @return [Nil, Rugged::Credentials::SshKey]
|
# @return [Nil, Rugged::Credentials::SshKey]
|
||||||
def credentials
|
def credentials_for(remote)
|
||||||
return unless File.exist? private_key
|
return unless File.exist? private_key
|
||||||
|
|
||||||
@credentials ||=
|
Rugged::Credentials::SshKey.new username: username_for(remote), 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]
|
||||||
|
|
Loading…
Reference in a new issue