diff --git a/app/jobs/git_pull_job.rb b/app/jobs/git_pull_job.rb new file mode 100644 index 00000000..de263403 --- /dev/null +++ b/app/jobs/git_pull_job.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# Permite traer los cambios cada vez que se +# hace un push al repositorio +class GitPullJob < ApplicationJob + # @param :site [Site] + # @param :usuarie [Usuarie] + # @return [nil] + def perform(site, usuarie) + site.repository.fetch + site.repository.merge(usuarie) + end +end \ No newline at end of file diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index 74d874c1..dd441863 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -45,7 +45,9 @@ class Site # @return [Integer] def fetch if origin.check_connection(:fetch, credentials: credentials) - rugged.fetch(origin, credentials: credentials)[:received_objects] + rugged.fetch(origin, credentials: credentials)[:received_objects].tap do |objects| + git_sh("git", "lfs", "fetch", "origin", default_branch) if objects&.positive? + end else 0 end @@ -75,6 +77,8 @@ class Site # Forzamos el checkout para mover el HEAD al Ășltimo commit y # escribir los cambios rugged.checkout 'HEAD', strategy: :force + # reemplaza los pointers por los archivos correspondientes + git_sh("git", "lfs", "checkout") commit end