A platform for community discussion. Free, open, simple.
DEV: In themes:update, only update themes which are out-of-date (#15676)
David Taylor6c3df84a9329
diff --git a/app/models/remote_theme.rb b/app/models/remote_theme.rbindex d19f800c827..10190ff064d 100644--- a/app/models/remote_theme.rb+++ b/app/models/remote_theme.rb@@ -112,6 +112,10 @@ class RemoteTheme < ActiveRecord::Baseself.joined_remotes.where("last_error_text IS NOT NULL").pluck("themes.name", "themes.id")end+ def out_of_date?+ commits_behind > 0 || remote_version != local_version+ end+def update_remote_versionreturn unless is_git?importer = ThemeStore::GitImporter.new(remote_url, private_key: private_key, branch: branch)diff --git a/lib/tasks/themes.rake b/lib/tasks/themes.rakeindex 88b85080afa..644c536e3aa 100644--- a/lib/tasks/themes.rake+++ b/lib/tasks/themes.rake@@ -58,9 +58,15 @@ def update_themesremote_theme = theme.remote_themenext if remote_theme.blank? || remote_theme.remote_url.blank?- puts "Updating '#{theme.name}' for '#{RailsMultisite::ConnectionManagement.current_db}'..."- remote_theme.update_from_remote- theme.save!+ print "Checking '#{theme.name}' for '#{RailsMultisite::ConnectionManagement.current_db}'... "+ remote_theme.update_remote_version+ if remote_theme.out_of_date?+ puts "updating from #{remote_theme.local_version[0..7]} to #{remote_theme.remote_version[0..7]}"+ remote_theme.update_from_remote+ theme.save!+ else+ puts "up to date"+ endraise RemoteTheme::ImportError.new(remote_theme.last_error_text) if remote_theme.last_error_text.present?rescue => e