From 656b0ae39e0069bc23785e7522045937641bd3ff Mon Sep 17 00:00:00 2001 From: Jeff Wong Date: Fri, 30 Apr 2021 06:31:41 -1000 Subject: [PATCH] DEV: Add an option to skip a theme update from the themes:install task. (#12905) A theme can now specify `skip_update: true` in the yml config for update allowing for the theme to be installed only if it does not already exist. --- app/services/themes_install_task.rb | 7 +++++-- lib/tasks/themes.rake | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/services/themes_install_task.rb b/app/services/themes_install_task.rb index 3fae7a9ff7983d..ac32739a1bf479 100644 --- a/app/services/themes_install_task.rb +++ b/app/services/themes_install_task.rb @@ -2,14 +2,17 @@ class ThemesInstallTask def self.install(themes) - counts = { installed: 0, updated: 0, errors: 0 } + counts = { installed: 0, updated: 0, errors: 0, skipped: 0 } log = [] themes.each do |name, val| installer = new(val) next if installer.url.nil? if installer.theme_exists? - if installer.update + if installer.options.fetch(:skip_update, nil) + log << "#{name}: is already installed. Skipping update." + counts[:skipped] += 1 + elsif installer.update log << "#{name}: is already installed. Updating from remote." counts[:updated] += 1 else diff --git a/lib/tasks/themes.rake b/lib/tasks/themes.rake index 8bd3e1010333b7..2de8b30a5a9ceb 100644 --- a/lib/tasks/themes.rake +++ b/lib/tasks/themes.rake @@ -45,6 +45,7 @@ task "themes:install" => :environment do |task, args| puts " Installed: #{counts[:installed]}" puts " Updated: #{counts[:updated]}" puts " Errors: #{counts[:errors]}" + puts " Skipped: #{counts[:skipped]}" if counts[:errors] > 0 exit 1