From f1052d2154324e0a19746d16c593cf2704a6023c Mon Sep 17 00:00:00 2001 From: f Date: Fri, 6 Sep 2024 13:41:02 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20reindexar=20desde=20el=20principio=20si?= =?UTF-8?q?=20cambi=C3=B3=20el=20repositorio=20#17359?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/site/index.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/models/site/index.rb b/app/models/site/index.rb index cfa4030a..1e256a9e 100644 --- a/app/models/site/index.rb +++ b/app/models/site/index.rb @@ -46,11 +46,19 @@ class Site private - # Trae el último commit indexado desde el repositorio + # Trae el último commit indexado desde el repositorio, o si no + # existe, trae el primer commit. # # @return [Rugged::Commit] def indexed_commit - @indexed_commit ||= repository.rugged.lookup(last_indexed_commit) + @indexed_commit ||= + if repository.rugged.exists?(last_indexed_commit) + repository.rugged.lookup(last_indexed_commit) + else + repository.rugged.lookup( + repository.rugged.references[repository.rugged.head.canonical_name].log.first[:id_new] + ) + end end # Calcula la diferencia entre el último commit indexado y el