5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-18 19:36:21 +00:00

Merge branch 'issue-14533' of https://0xacab.org/sutty/sutty into 17.3.alpine.panel.sutty.nl

This commit is contained in:
Sutty 2023-10-31 16:57:39 +00:00
commit 854389a031
5 changed files with 51 additions and 16 deletions

View file

@ -68,7 +68,7 @@ module Api
# respuesta de error a plataformas # respuesta de error a plataformas
def platforms_answer(exception) def platforms_answer(exception)
ExceptionNotifier.notify_exception(exception, env: request.env, data: { headers: request.headers.to_h }) ExceptionNotifier.notify_exception(exception, data: { headers: request.headers.to_h }
head :forbidden head :forbidden
end end

View file

@ -1,7 +1,6 @@
# frozen_string_literal: true # frozen_string_literal: true
# Permite traer los cambios desde webhooks # Permite traer los cambios desde el repositorio remoto
class GitPullJob < ApplicationJob class GitPullJob < ApplicationJob
# @param :site [Site] # @param :site [Site]
# @param :usuarie [Usuarie] # @param :usuarie [Usuarie]
@ -9,9 +8,20 @@ class GitPullJob < ApplicationJob
# @return [nil] # @return [nil]
def perform(site, usuarie, message) def perform(site, usuarie, message)
return unless site.repository.origin return unless site.repository.origin
return unless site.repository.fetch.positive?
site.repository.merge(usuarie, message) site.repository.fetch
return if site.repository.up_to_date?
if site.repository.fast_forward?
site.repository.fast_forward!
else
site.repository.merge(usuarie, message)
end
git_lfs_checkout
site.reindex_changes! site.reindex_changes!
nil
end end
end end

View file

@ -76,12 +76,17 @@ class Site
# escribir los cambios # escribir los cambios
rugged.checkout 'HEAD', strategy: :force rugged.checkout 'HEAD', strategy: :force
git_sh("git", "lfs", "fetch", "origin", default_branch)
# reemplaza los pointers por los archivos correspondientes
git_sh("git", "lfs", "checkout")
commit commit
end end
# Trae todos los archivos desde LFS
#
# @return [Boolean]
def git_lfs_checkout
git_sh('git', 'lfs', 'fetch', 'origin', default_branch)
git_sh('git', 'lfs', 'checkout')
end
# El último commit # El último commit
# #
# @return [Rugged::Commit] # @return [Rugged::Commit]
@ -111,10 +116,30 @@ class Site
walker.each.to_a walker.each.to_a
end end
# Hay commits sin aplicar? # Detecta si hay que hacer un pull o no
def needs_pull? #
fetch # @return [Boolean]
!commits.empty? def up_to_date?
rugged.merge_analysis(remote_head_commit).include?(:up_to_date)
end
# Detecta si es posible adelantar la historia local a la remota o
# necesitamos un merge
#
# @return [Boolean]
def fast_forward?
rugged.merge_analysis(remote_head_commit).include?(:fastforward)
end
# Mueve la historia local a la remota
#
# @see {https://stackoverflow.com/a/27077322}
# @return [nil]
def fast_forward!
rugged.checkout_tree(remote_head_commit)
rugged.references.update(rugged.head.resolve, remote_head_commit.oid)
nil
end end
# Guarda los cambios en git # Guarda los cambios en git

View file

@ -125,8 +125,8 @@ module Jekyll
unless spec unless spec
I18n.with_locale(locale) do I18n.with_locale(locale) do
raise ArgumentError, I18n.t('activerecord.errors.models.site.attributes.design_id.missing_gem', theme: name) raise Jekyll::Errors::InvalidThemeName, I18n.t('activerecord.errors.models.site.attributes.design_id.missing_gem', theme: name)
rescue ArgumentError => e rescue Jekyll::Errors::InvalidThemeName => e
ExceptionNotifier.notify_exception(e, data: { theme: name, site: File.basename(site.source) }) ExceptionNotifier.notify_exception(e, data: { theme: name, site: File.basename(site.source) })
raise raise
end end

View file

@ -18,7 +18,7 @@
- name_en: 'Minima' - name_en: 'Minima'
name_es: 'Mínima' name_es: 'Mínima'
gem: 'sutty-minima' gem: 'sutty-minima'
url: 'https://0xacab.org/sutty/jekyll/minima' url: 'https://minima.sutty.nl/'
description_en: "Sutty Minima is based on [Minima](https://jekyll.github.io/minima/), a blog-focused theme for Jekyll." description_en: "Sutty Minima is based on [Minima](https://jekyll.github.io/minima/), a blog-focused theme for Jekyll."
description_es: 'Sutty Mínima es una plantilla para blogs basada en [Mínima](https://jekyll.github.io/minima/).' description_es: 'Sutty Mínima es una plantilla para blogs basada en [Mínima](https://jekyll.github.io/minima/).'
license: 'https://0xacab.org/sutty/jekyll/minima/-/blob/master/LICENSE.txt' license: 'https://0xacab.org/sutty/jekyll/minima/-/blob/master/LICENSE.txt'