From 9ec0dc87a9426a3a101416e5044b40d8e274f08e Mon Sep 17 00:00:00 2001 From: f Date: Tue, 31 Oct 2023 13:53:45 -0300 Subject: [PATCH] fix: hacer un merge cuando hay cambios #14533 --- app/jobs/git_pull_job.rb | 6 +++++- app/models/site/repository.rb | 9 +++++---- 2 files changed, 10 insertions(+), 5 deletions(-) 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