From 1c33b169188bcf46e1ba863481b5127f77ad21c9 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Tue, 9 Jun 2026 14:58:47 +0200 Subject: [PATCH 1/3] Fix #4072 --- app/services/git/providers/abstract.rb | 12 ++++++++++ app/services/git/providers/github.rb | 11 +++++++++- .../git/providers/github/with_theme.rb | 22 ------------------- app/services/git/providers/gitlab.rb | 8 ++++++- 4 files changed, 29 insertions(+), 24 deletions(-) delete mode 100644 app/services/git/providers/github/with_theme.rb diff --git a/app/services/git/providers/abstract.rb b/app/services/git/providers/abstract.rb index e3bdd555ac..e153705a21 100644 --- a/app/services/git/providers/abstract.rb +++ b/app/services/git/providers/abstract.rb @@ -58,4 +58,16 @@ def files_in_the_repository def batch @batch ||= [] end + + def current_theme_sha + @current_theme_sha ||= Osuny::ThemeInfo.get_current_sha + end + + def previous_theme_sha + @previous_theme_sha ||= git_sha(ENV["GITHUB_WEBSITE_THEME_PATH"]) + end + + def should_update_theme? + previous_theme_sha != current_theme_sha + end end diff --git a/app/services/git/providers/github.rb b/app/services/git/providers/github.rb index 3c0346617f..8ae08d7c4b 100644 --- a/app/services/git/providers/github.rb +++ b/app/services/git/providers/github.rb @@ -3,7 +3,6 @@ class Git::Providers::Github < Git::Providers::Abstract COMMIT_BATCH_SIZE = 30 include WithSecrets - include WithTheme def url "#{BASE_URL}/#{repository}" @@ -56,6 +55,16 @@ def destroy_file(path) } end + def update_theme + return unless should_update_theme? + batch << { + path: ENV["GITHUB_WEBSITE_THEME_PATH"], + mode: '160000', + type: 'commit', + sha: current_theme_sha + } + end + def init_from_template(name) client.create_repository_from_template( ENV['GITHUB_WEBSITE_TEMPLATE_REPOSITORY'], diff --git a/app/services/git/providers/github/with_theme.rb b/app/services/git/providers/github/with_theme.rb deleted file mode 100644 index db55f279da..0000000000 --- a/app/services/git/providers/github/with_theme.rb +++ /dev/null @@ -1,22 +0,0 @@ -module Git::Providers::Github::WithTheme - extend ActiveSupport::Concern - - def update_theme - batch << { - path: ENV["GITHUB_WEBSITE_THEME_PATH"], - mode: '160000', - type: 'commit', - sha: current_theme_sha - } if previous_theme_sha != current_theme_sha - end - - protected - - def current_theme_sha - @current_theme_sha ||= Osuny::ThemeInfo.get_current_sha - end - - def previous_theme_sha - @previous_theme_sha ||= git_sha(ENV["GITHUB_WEBSITE_THEME_PATH"]) - end -end \ No newline at end of file diff --git a/app/services/git/providers/gitlab.rb b/app/services/git/providers/gitlab.rb index 7cf2c5c0c9..2fc20971a2 100644 --- a/app/services/git/providers/gitlab.rb +++ b/app/services/git/providers/gitlab.rb @@ -41,7 +41,13 @@ def destroy_file(path) end def update_theme - raise NoMethodError, "You must implement the `update_theme` method in #{self.class.name}" + return unless should_update_theme? + batch << { + action: 'update', + file_path: ENV["GITHUB_WEBSITE_THEME_PATH"], + type: 'commit', + sha: current_theme_sha + } end def init_from_template(name) From 995e66b4c07513c837f6caec12de7d01f97b8733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= Date: Mon, 15 Jun 2026 10:03:29 +0200 Subject: [PATCH 2/3] Fix GitLab theme update via submodules API --- app/services/git/providers/abstract.rb | 5 +++++ app/services/git/providers/github.rb | 1 + app/services/git/providers/gitlab.rb | 13 +++++++------ app/services/git/repository.rb | 2 -- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/services/git/providers/abstract.rb b/app/services/git/providers/abstract.rb index e153705a21..9ae8d4e199 100644 --- a/app/services/git/providers/abstract.rb +++ b/app/services/git/providers/abstract.rb @@ -70,4 +70,9 @@ def previous_theme_sha def should_update_theme? previous_theme_sha != current_theme_sha end + + def update_theme_message + theme_name = ENV["GITHUB_WEBSITE_THEME_REPOSITORY"].to_s.split("/").last + "Updated #{theme_name} version" + end end diff --git a/app/services/git/providers/github.rb b/app/services/git/providers/github.rb index 8ae08d7c4b..1121eae6b3 100644 --- a/app/services/git/providers/github.rb +++ b/app/services/git/providers/github.rb @@ -63,6 +63,7 @@ def update_theme type: 'commit', sha: current_theme_sha } + push(update_theme_message) end def init_from_template(name) diff --git a/app/services/git/providers/gitlab.rb b/app/services/git/providers/gitlab.rb index 2fc20971a2..8feed4e509 100644 --- a/app/services/git/providers/gitlab.rb +++ b/app/services/git/providers/gitlab.rb @@ -42,12 +42,13 @@ def destroy_file(path) def update_theme return unless should_update_theme? - batch << { - action: 'update', - file_path: ENV["GITHUB_WEBSITE_THEME_PATH"], - type: 'commit', - sha: current_theme_sha - } + client.edit_submodule repository, + ENV["GITHUB_WEBSITE_THEME_PATH"], + { + branch: branch, + commit_sha: current_theme_sha, + commit_message: update_theme_message + } end def init_from_template(name) diff --git a/app/services/git/repository.rb b/app/services/git/repository.rb index c458892e8f..9c11532287 100644 --- a/app/services/git/repository.rb +++ b/app/services/git/repository.rb @@ -25,8 +25,6 @@ def sync! def update_theme_version! provider.update_theme - theme_name = ENV["GITHUB_WEBSITE_THEME_REPOSITORY"].to_s.split("/").last - provider.push("Updated #{theme_name} version") end # Based on content, with the provider's algorithm (sha1 or sha256) From 2cb68ae0534b76ba9b2d933345e00f9da5dcb0d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= Date: Mon, 15 Jun 2026 10:13:17 +0200 Subject: [PATCH 3/3] update_theme => update_theme! & update_theme_message => theme_update_commit_message --- app/services/git/providers/abstract.rb | 6 +++--- app/services/git/providers/github.rb | 4 ++-- app/services/git/providers/gitlab.rb | 4 ++-- app/services/git/repository.rb | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/services/git/providers/abstract.rb b/app/services/git/providers/abstract.rb index 9ae8d4e199..294b336cf5 100644 --- a/app/services/git/providers/abstract.rb +++ b/app/services/git/providers/abstract.rb @@ -29,8 +29,8 @@ def destroy_file(path) raise NoMethodError, "You must implement the `destroy_file` method in #{self.class.name}" end - def update_theme - raise NoMethodError, "You must implement the `update_theme` method in #{self.class.name}" + def update_theme! + raise NoMethodError, "You must implement the `update_theme!` method in #{self.class.name}" end def push(commit_message) @@ -71,7 +71,7 @@ def should_update_theme? previous_theme_sha != current_theme_sha end - def update_theme_message + def theme_update_commit_message theme_name = ENV["GITHUB_WEBSITE_THEME_REPOSITORY"].to_s.split("/").last "Updated #{theme_name} version" end diff --git a/app/services/git/providers/github.rb b/app/services/git/providers/github.rb index 1121eae6b3..edf5572297 100644 --- a/app/services/git/providers/github.rb +++ b/app/services/git/providers/github.rb @@ -55,7 +55,7 @@ def destroy_file(path) } end - def update_theme + def update_theme! return unless should_update_theme? batch << { path: ENV["GITHUB_WEBSITE_THEME_PATH"], @@ -63,7 +63,7 @@ def update_theme type: 'commit', sha: current_theme_sha } - push(update_theme_message) + push(theme_update_commit_message) end def init_from_template(name) diff --git a/app/services/git/providers/gitlab.rb b/app/services/git/providers/gitlab.rb index 8feed4e509..67144b8f15 100644 --- a/app/services/git/providers/gitlab.rb +++ b/app/services/git/providers/gitlab.rb @@ -40,14 +40,14 @@ def destroy_file(path) } end - def update_theme + def update_theme! return unless should_update_theme? client.edit_submodule repository, ENV["GITHUB_WEBSITE_THEME_PATH"], { branch: branch, commit_sha: current_theme_sha, - commit_message: update_theme_message + commit_message: theme_update_commit_message } end diff --git a/app/services/git/repository.rb b/app/services/git/repository.rb index 9c11532287..29073b4186 100644 --- a/app/services/git/repository.rb +++ b/app/services/git/repository.rb @@ -24,7 +24,7 @@ def sync! end def update_theme_version! - provider.update_theme + provider.update_theme! end # Based on content, with the provider's algorithm (sha1 or sha256)