From e2d6b712e1117bd481b24856c82535be81f8641d Mon Sep 17 00:00:00 2001 From: f Date: Sat, 18 Jul 2020 10:37:46 -0300 Subject: [PATCH] notificar cuando no se puede actualizar un sitio --- app/lib/merge_conflicts_exception.rb | 3 +++ app/models/deploy_local.rb | 2 +- app/models/site/repository.rb | 13 +++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 app/lib/merge_conflicts_exception.rb diff --git a/app/lib/merge_conflicts_exception.rb b/app/lib/merge_conflicts_exception.rb new file mode 100644 index 00000000..0c6638bc --- /dev/null +++ b/app/lib/merge_conflicts_exception.rb @@ -0,0 +1,3 @@ +# frozen_string_literal: true + +class MergeConflictsException < RuntimeError; end diff --git a/app/models/deploy_local.rb b/app/models/deploy_local.rb index 24efd533..aeeb603c 100644 --- a/app/models/deploy_local.rb +++ b/app/models/deploy_local.rb @@ -86,7 +86,7 @@ class DeployLocal < Deploy end def jekyll_build - run "bundle exec jekyll build --trace --destination \"#{escaped_destination}\"" + run %(bundle exec jekyll build --trace --destination "#{escaped_destination}") end # no debería haber espacios ni caracteres especiales, pero por si diff --git a/app/models/site/repository.rb b/app/models/site/repository.rb index 1923d06d..d63e331c 100644 --- a/app/models/site/repository.rb +++ b/app/models/site/repository.rb @@ -36,12 +36,13 @@ class Site def merge(usuarie) merge = rugged.merge_commits(master, origin_master) - # No hacemos nada si hay conflictos - # - # TODO: Enviar un correo a administración para poder revisar - # manualmente. Idealmente no deberíamos tener conflictos pero - # quién sabe. - return if merge.conflicts? + # No hacemos nada si hay conflictos, pero notificarnos + begin + raise MergeConflictsException if merge.conflicts? + rescue MergeConflictsException => e + ExceptionNotifier.notify_exception(e, data: { path: path, merge: merge }) + return # No hacer nada + end commit = Rugged::Commit .create(rugged, update_ref: 'HEAD',