mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-15 10:41:42 +00:00
Merge branch 'ssh-git' into 'rails'
poder traer actualizaciones desde repositorios remotos Closes #1837 See merge request sutty/sutty!36
This commit is contained in:
commit
ba8b80fca0
1 changed files with 22 additions and 2 deletions
|
@ -44,8 +44,8 @@ class Site
|
|||
#
|
||||
# @return [Integer]
|
||||
def fetch
|
||||
if origin.check_connection :fetch
|
||||
rugged.fetch(origin)[:received_objects]
|
||||
if origin.check_connection(:fetch, credentials: credentials)
|
||||
rugged.fetch(origin, credentials: credentials)[:received_objects]
|
||||
else
|
||||
0
|
||||
end
|
||||
|
@ -149,6 +149,26 @@ class Site
|
|||
|
||||
private
|
||||
|
||||
# Si Sutty tiene una llave privada de tipo ED25519, devuelve las
|
||||
# credenciales necesarias para trabajar con repositorios remotos.
|
||||
#
|
||||
# @return [Nil, Rugged::Credentials::SshKey]
|
||||
def credentials
|
||||
return unless File.exist? private_key
|
||||
|
||||
@credentials ||= Rugged::Credentials::SshKey.new username: 'git', publickey: public_key, privatekey: private_key
|
||||
end
|
||||
|
||||
# @return [String]
|
||||
def public_key
|
||||
@public_key ||= Rails.root.join('.ssh', 'id_ed25519.pub').to_s
|
||||
end
|
||||
|
||||
# @return [String]
|
||||
def private_key
|
||||
@private_key ||= Rails.root.join('.ssh', 'id_ed25519').to_s
|
||||
end
|
||||
|
||||
def relativize(file)
|
||||
Pathname.new(file).relative_path_from(Pathname.new(path)).to_s
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue