diff --git a/app/jobs/git_push_job.rb b/app/jobs/git_push_job.rb index fb3ca662..3c62bee2 100644 --- a/app/jobs/git_push_job.rb +++ b/app/jobs/git_push_job.rb @@ -6,7 +6,6 @@ class GitPushJob < ApplicationJob # @param :site [Site] # @return [nil] def perform(site) - #detectar que el repo local tiene repo remoto site.repository.push if site.repository.origin end end \ No newline at end of file diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index 10ab481d..6306730e 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -154,7 +154,7 @@ class Site # # @return [Boolean] def gc - git_sh("git gc") + git_sh("git", "gc") end # Pushea cambios al repositorio remoto @@ -162,7 +162,7 @@ class Site # @return [Boolean, nil] def push origin.push(rugged.head.canonical_name, credentials: credentials) - git_sh("git lfs push") + git_sh("git", "lfs", "push", "origin", "#{default_branch}") end private @@ -191,11 +191,15 @@ class Site Pathname.new(file).relative_path_from(Pathname.new(path)).to_s end - def git_sh(cmd) + # 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, cmd, unsetenv_others: true, chdir: path) do |_, _, t| + Open3.popen2e(env, args, unsetenv_others: true, chdir: path) do |_, _, t| r = t.value end