Merge pull request #179 from abf/rosa-build:use-shellescape-on-system-actions

Use #shellescape on system actions (part 2)
This commit is contained in:
avokhmin 2013-06-17 21:26:10 +04:00
commit ae714518c6
2 changed files with 22 additions and 3 deletions

View File

@ -164,7 +164,7 @@ class PullRequest < ActiveRecord::Base
def merge
clone
message = "Merge pull request ##{serial_id} from #{from_project_owner_uname}/#{from_project_name}:#{from_ref}\r\n #{title}"
%x(cd #{path} && git checkout #{to_ref} && git merge --no-ff #{from_branch} -m #{message.shellescape})
%x(cd #{path} && git checkout #{to_ref.shellescape} && git merge --no-ff #{from_branch.shellescape} -m #{message.shellescape})
end
def clone
@ -194,8 +194,9 @@ class PullRequest < ActiveRecord::Base
system 'git', 'reset', '--hard', "origin/#{to_ref}"
end
unless tags.include? from_ref
system 'git', 'branch', '-D', from_branch
system 'git', 'fetch', head, "+#{from_ref}:#{from_branch}"
system 'git', 'checkout', from_branch
system 'git', 'reset', '--hard', "#{head}/#{from_ref}"
system 'git', 'checkout', to_ref
end
end
end

View File

@ -1,4 +1,20 @@
# -*- encoding : utf-8 -*-
class DisableAssetsLogger
def initialize(app)
@app = app
Rails.application.assets.logger = Logger.new('/dev/null')
end
def call(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
@app.call(env)
ensure
Rails.logger.level = previous_level
end
end
Rosa::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
@ -40,4 +56,6 @@ Rosa::Application.configure do
# Log the query plan for queries taking more than this (works with SQLite, MySQL, and PostgreSQL)
config.active_record.auto_explain_threshold_in_seconds = 0.5
config.middleware.insert_before Rails::Rack::Logger, DisableAssetsLogger
end