diff --git a/app/models/site.rb b/app/models/site.rb index 469e202e..504e4c9d 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -477,7 +477,10 @@ class Site < ApplicationRecord def clone_skel! return if jekyll? - Rugged::Repository.clone_at(ENV['SKEL_SUTTY'], path, checkout_branch: design.gem, remote: 'upstream') + Rugged::Repository.clone_at(ENV['SKEL_SUTTY'], path, checkout_branch: design.gem + + # Necesita un bloque + repository.rugged.remotes.rename('origin', 'upstream') {} end # Elimina el directorio del sitio diff --git a/app/services/post_service.rb b/app/services/post_service.rb index dda7992d..4631a9a4 100644 --- a/app/services/post_service.rb +++ b/app/services/post_service.rb @@ -102,6 +102,8 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do usuarie: usuarie, message: I18n.t("post_service.#{action}", title: post&.title&.value)) + + GitPushJob.perform_later(site) end # Solo permitir cambiar estos atributos de cada articulo diff --git a/app/services/site_service.rb b/app/services/site_service.rb index b9a121e6..762c8728 100644 --- a/app/services/site_service.rb +++ b/app/services/site_service.rb @@ -97,6 +97,8 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do add: [site.config.path], message: I18n.t("site_service.#{action}", name: site.name)) + + GitPushJob.perform_later(site) end def add_role(temporal: true, rol: 'invitade') diff --git a/db/migrate/20230921155401_site_rename_origin_to_upstream.rb b/db/migrate/20230921155401_site_rename_origin_to_upstream.rb new file mode 100644 index 00000000..c27d7747 --- /dev/null +++ b/db/migrate/20230921155401_site_rename_origin_to_upstream.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +# Renombrar todos los repositorios que apunten a skel como su origin +class SiteRenameOriginToUpstream < ActiveRecord::Migration[6.1] + # Renombrar + def up + Site.find_each do |site| + next unless site.repository.origin&.url == ENV['SKEL_SUTTY'] + + site.repository.rugged.remotes.rename('origin', 'upstream') + rescue Rugged::Error => e + Rails.logger.warn "#{site.name}: #{e.message}" + end + end + + # No se puede deshacer + def down; end +end