diff --git a/app/jobs/git_pull_job.rb b/app/jobs/git_pull_job.rb index dc4a285c..c7063650 100644 --- a/app/jobs/git_pull_job.rb +++ b/app/jobs/git_pull_job.rb @@ -8,6 +8,10 @@ class GitPullJob < ApplicationJob # @param :message [String] # @return [nil] def perform(site, usuarie, message) - site.repository.merge(usuarie, message) if site.repository.fetch&.positive? + site.repository.fetch + + return if site.repository.up_to_date? + + site.repository.merge(usuarie, message) end end \ No newline at end of file diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index acbf6553..17ee0792 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -111,10 +111,11 @@ class Site walker.each.to_a end - # Hay commits sin aplicar? - def needs_pull? - fetch - !commits.empty? + # Detecta si hay que hacer un pull o no + # + # @return [Boolean] + def up_to_date? + rugged.merge_analysis(remote_head_commit).include?(:up_to_date) end # Guarda los cambios en git