mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-15 23:21:41 +00:00
Merge branch 'issue-12919' into issue-12980
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Mergea cambios en repository.rb
This commit is contained in:
commit
ca67665107
2 changed files with 35 additions and 11 deletions
11
app/jobs/git_push_job.rb
Normal file
11
app/jobs/git_push_job.rb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Permite pushear los cambios cada vez que se
|
||||||
|
# hacen commits en un sitio
|
||||||
|
class GitPushJob < ApplicationJob
|
||||||
|
# @param :site [Site]
|
||||||
|
# @return [nil]
|
||||||
|
def perform(site)
|
||||||
|
site.repository.push if site.repository.origin
|
||||||
|
end
|
||||||
|
end
|
|
@ -29,7 +29,7 @@ class Site
|
||||||
|
|
||||||
# Obtiene el origin
|
# Obtiene el origin
|
||||||
#
|
#
|
||||||
# @return [Rugged::Remote]
|
# @return [Rugged::Remote, nil]
|
||||||
def origin
|
def origin
|
||||||
@origin ||= rugged.remotes.find do |remote|
|
@origin ||= rugged.remotes.find do |remote|
|
||||||
remote.name == 'origin'
|
remote.name == 'origin'
|
||||||
|
@ -158,17 +158,15 @@ class Site
|
||||||
#
|
#
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
def gc
|
def gc
|
||||||
env = { 'PATH' => '/usr/bin', 'LANG' => ENV['LANG'], 'HOME' => path }
|
git_sh("git", "gc")
|
||||||
cmd = 'git gc'
|
end
|
||||||
|
|
||||||
r = nil
|
# Pushea cambios al repositorio remoto
|
||||||
Dir.chdir(path) do
|
#
|
||||||
Open3.popen2e(env, cmd, unsetenv_others: true) do |_, _, t|
|
# @return [Boolean, nil]
|
||||||
r = t.value
|
def push
|
||||||
end
|
origin.push(rugged.head.canonical_name, credentials: credentials)
|
||||||
end
|
git_sh("git", "lfs", "push", "origin", default_branch)
|
||||||
|
|
||||||
r&.success?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -196,5 +194,20 @@ class Site
|
||||||
def relativize(file)
|
def relativize(file)
|
||||||
Pathname.new(file).relative_path_from(Pathname.new(path)).to_s
|
Pathname.new(file).relative_path_from(Pathname.new(path)).to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Ejecuta un comando de git
|
||||||
|
#
|
||||||
|
# @param :args [Array]
|
||||||
|
# @return [Boolean]
|
||||||
|
def git_sh(*args)
|
||||||
|
env = { 'PATH' => '/usr/bin', 'LANG' => ENV['LANG'], 'HOME' => path }
|
||||||
|
|
||||||
|
r = nil
|
||||||
|
Open3.popen2e(env, *args, unsetenv_others: true, chdir: path) do |_, _, t|
|
||||||
|
r = t.value
|
||||||
|
end
|
||||||
|
|
||||||
|
r&.success?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue