diff --git a/app/models/remote_theme.rb b/app/models/remote_theme.rb index d19f800c827..10190ff064d 100644 --- a/app/models/remote_theme.rb +++ b/app/models/remote_theme.rb @@ -112,6 +112,10 @@ class RemoteTheme < ActiveRecord::Base self.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_version return 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.rake index 88b85080afa..644c536e3aa 100644 --- a/lib/tasks/themes.rake +++ b/lib/tasks/themes.rake @@ -58,9 +58,15 @@ def update_themes remote_theme = theme.remote_theme next 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" + end raise RemoteTheme::ImportError.new(remote_theme.last_error_text) if remote_theme.last_error_text.present? rescue => e