From af4b246ce537170f94bfe8be5f1bbde914f60155 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 11 Sep 2012 09:26:15 +0100 Subject: A rake task to populate the request classification table based on any existing status update info request events. --- lib/tasks/temp.rake | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/tasks') diff --git a/lib/tasks/temp.rake b/lib/tasks/temp.rake index 9decc13db..e49a84ecb 100644 --- a/lib/tasks/temp.rake +++ b/lib/tasks/temp.rake @@ -1,5 +1,14 @@ namespace :temp do + desc 'Populate the request_classifications table from info_request_events' + task :populate_request_classifications => :environment do + InfoRequestEvent.find_each(:conditions => ["event_type = 'status_update'"]) do |classification| + RequestClassification.create!(:created_at => classification.created_at, + :user_id => classification.params[:user_id], + :info_request_event_id => classification.id) + end + end + desc "Remove plaintext passwords from post_redirect params" task :remove_post_redirect_passwords => :environment do PostRedirect.find_each(:conditions => ['post_params_yaml is not null']) do |post_redirect| -- cgit v1.2.3 From 926ab82ada79adea9d0092898e0ee60c9ff6e53e Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 11 Sep 2012 13:08:21 +0100 Subject: Simpler usage of git when trying to get usage tags for themes. Also for ALAVETELI_VERSIONS with more than 4 sequence elements (hotfixes), if we can't find an exactly matching usage tag, look for one matching the related minor release. This should prevent unexpected switching to HEAD for themes with no matching usage tag for that hotfix. --- lib/tasks/themes.rake | 58 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 24 deletions(-) (limited to 'lib/tasks') diff --git a/lib/tasks/themes.rake b/lib/tasks/themes.rake index 2b1dbb3a9..6eb64b4b0 100644 --- a/lib/tasks/themes.rake +++ b/lib/tasks/themes.rake @@ -9,33 +9,43 @@ namespace :themes do File.join(plugin_dir, theme_name) end + def checkout_tag(version) + checkout_command = "git checkout #{usage_tag(version)}" + success = system(checkout_command) + puts "Using tag #{usage_tag(version)}" if verbose && success + success + end + + def usage_tag(version) + "use-with-alaveteli-#{version}" + end + def install_theme_using_git(name, uri, verbose=false, options={}) - mkdir_p(install_path = theme_dir(name)) - Dir.chdir install_path do - init_cmd = "git init" - init_cmd += " -q" if options[:quiet] and not verbose - puts init_cmd if verbose - system(init_cmd) - base_cmd = "git pull --depth 1 #{uri}" - # Is there a tag for this version of Alaveteli? - usage_tag = "use-with-alaveteli-#{ALAVETELI_VERSION}" - # Query the remote repository passing flags for tags - version_tag = `git ls-remote --tags #{uri} #{usage_tag}` - if /^[a-z0-9]+\s+refs\/tags\/#{Regexp.escape(usage_tag)}$/.match(version_tag) - # If we got a tag, pull that instead of HEAD - puts "Using tag #{usage_tag}" if verbose - base_cmd += " refs/tags/#{usage_tag}" - else - puts "No specific tag for this version: using HEAD" if verbose - end - base_cmd += " -q" if options[:quiet] and not verbose - puts base_cmd if verbose - if system(base_cmd) - puts "removing: .git .gitignore" if verbose - rm_rf %w(.git .gitignore) + install_path = theme_dir(name) + Dir.chdir(plugin_dir) do + clone_command = "git clone #{uri} #{name}" + if system(clone_command) + Dir.chdir install_path do + # try to checkout a tag exactly matching ALAVETELI VERSION + tag_checked_out = checkout_tag(ALAVETELI_VERSION) + if ! tag_checked_out + # if we're on a hotfix release (four sequence elements or more), + # look for a usage tag matching the minor release (three sequence elements) + # and check that out if found + if hotfix_version = /^(\d+\.\d+\.\d+)(\.\d+)+/.match(ALAVETELI_VERSION) + base_version = hotfix_version[1] + tag_checked_out = checkout_tag(base_version) + end + end + if ! tag_checked_out + puts "No specific tag for this version: using HEAD" if verbose + end + puts "removing: .git .gitignore" if verbose + rm_rf %w(.git .gitignore) + end else rm_rf install_path - raise "#{base_cmd} failed! Stopping." + raise "#{clone_command} failed! Stopping." end end end -- cgit v1.2.3