#860: merge master into branch

This commit is contained in:
Vokhmin Alexey V 2013-01-29 23:23:52 +04:00
commit ad08a31e5f
11 changed files with 78 additions and 25 deletions

View File

@ -1708,3 +1708,12 @@ table#myTable thead tr.search th form.button_to div input {
margin-top: 2px; margin-top: 2px;
} }
.file-editor {
margin-bottom: 10px;
margin-top: 10px;
max-width: 860px;
}
.CodeMirror {
border: 1px solid #DDDDDD;
}

View File

@ -12,8 +12,7 @@ class Platforms::MassBuildsController < Platforms::BaseController
def create def create
mass_build = @platform.mass_builds.new(:arches => params[:arches], mass_build = @platform.mass_builds.new(:arches => params[:arches],
:auto_publish => params[:auto_publish] || false, :auto_publish => params[:auto_publish] || false,
:projects_list => params[:projects_list], :projects_list => params[:projects_list])
:new_core => params[:new_core])
mass_build.user = current_user mass_build.user = current_user
authorize! :create, mass_build authorize! :create, mass_build

View File

@ -7,7 +7,7 @@ class MassBuild < ActiveRecord::Base
scope :outdated, where('created_at < ?', Time.now + 1.day - BuildList::MAX_LIVE_TIME) scope :outdated, where('created_at < ?', Time.now + 1.day - BuildList::MAX_LIVE_TIME)
attr_accessor :arches attr_accessor :arches
attr_accessible :arches, :auto_publish, :projects_list, :new_core attr_accessible :arches, :auto_publish, :projects_list
validates :platform_id, :arch_names, :name, :user_id, :projects_list, :presence => true validates :platform_id, :arch_names, :name, :user_id, :projects_list, :presence => true
validates_inclusion_of :auto_publish, :in => [true, false] validates_inclusion_of :auto_publish, :in => [true, false]
@ -21,7 +21,9 @@ class MassBuild < ActiveRecord::Base
:build_pending, :build_pending,
:build_started, :build_started,
:build_publish, :build_publish,
:build_error :build_error,
:success,
:build_canceled
] ]
def build_all def build_all
@ -38,7 +40,7 @@ class MassBuild < ActiveRecord::Base
return if self.reload.stop_build return if self.reload.stop_build
arches_list.each do |arch| arches_list.each do |arch|
rep = (project.repositories & platform.repositories).first rep = (project.repositories & platform.repositories).first
project.build_for(platform, rep.id, user, arch, auto_publish, self.id, 0, new_core) project.build_for(platform, rep.id, user, arch, auto_publish, self.id, 0)
end end
rescue RuntimeError, Exception rescue RuntimeError, Exception
end end
@ -47,7 +49,6 @@ class MassBuild < ActiveRecord::Base
list = (missed_projects_list || '') << "#{name}\n" list = (missed_projects_list || '') << "#{name}\n"
update_column :missed_projects_list, list update_column :missed_projects_list, list
end end
sleep 1 unless new_core
end end
end end
later :build_all, :queue => :clone_build later :build_all, :queue => :clone_build

View File

@ -130,7 +130,7 @@ class Project < ActiveRecord::Base
#path #share by NFS #path #share by NFS
end end
def build_for(platform, repository_id, user, arch = Arch.find_by_name('i586'), auto_publish = false, mass_build_id = nil, priority = 0, new_core = false) def build_for(platform, repository_id, user, arch = Arch.find_by_name('i586'), auto_publish = false, mass_build_id = nil, priority = 0)
# Select main and project platform repository(contrib, non-free and etc) # Select main and project platform repository(contrib, non-free and etc)
# If main does not exist, will connect only project platform repository # If main does not exist, will connect only project platform repository
# If project platform repository is main, only main will be connect # If project platform repository is main, only main will be connect
@ -151,7 +151,6 @@ class Project < ActiveRecord::Base
bl.priority = priority bl.priority = priority
bl.mass_build_id = mass_build_id bl.mass_build_id = mass_build_id
bl.save_to_repository_id = repository_id bl.save_to_repository_id = repository_id
bl.new_core = new_core
end end
build_list.save build_list.save
end end

View File

@ -48,6 +48,11 @@ class PullRequest < ActiveRecord::Base
end end
def check(do_transaction = true) def check(do_transaction = true)
if do_transaction && !valid?
issue.set_close nil
issue.save(:validate => false) # FIXME remove this hack
return false
end
res = merge res = merge
new_status = case res new_status = case res
when /Already up-to-date/ when /Already up-to-date/
@ -171,16 +176,18 @@ class PullRequest < ActiveRecord::Base
end end
Dir.chdir(path) do Dir.chdir(path) do
system 'git', 'tag', '-d', from_ref, to_ref
system 'git fetch --tags'
tags, head = repo.tags.map(&:name), to_project == from_project ? 'origin' : 'head'
unless tags.include? to_ref
system 'git', 'checkout', to_ref system 'git', 'checkout', to_ref
system 'git', 'pull', 'origin', to_ref system 'git', 'reset', '--hard', "origin/#{to_ref}"
if to_project_id == from_project_id end
system 'git', 'checkout', from_ref unless tags.include? from_ref
system 'git', 'pull', 'origin', from_ref system 'git', 'branch', '-D', from_branch
else system 'git', 'fetch', head, "+#{from_ref}:#{from_branch}"
system 'git', 'fetch', 'head', "+#{from_ref}:#{from_branch}"
end end
end end
# TODO catch errors
end end
def clean def clean

View File

@ -5,7 +5,7 @@
.both .both
= form_tag edit_blob_path(@project, @treeish, @path), :name => 'blob-editor', :method => :put do = form_tag edit_blob_path(@project, @treeish, @path), :name => 'blob-editor', :method => :put do
.file= text_area_tag :content, @blob.data, :id => 'code' .file-editor= text_area_tag :content, @blob.data, :id => 'code'
.both .both
= t("layout.enter_commit_message") = t("layout.enter_commit_message")
@ -23,4 +23,12 @@
lineNumbers: true, lineNumbers: true,
mode: '#{@blob.raw_mime_type.content_type}' mode: '#{@blob.raw_mime_type.content_type}'
}); });
$(".CodeMirror").resizable({
stop: function() { editor.refresh(); },
resize: function() {
$(".CodeMirror-scroll").height($(this).height());
$(".CodeMirror-scroll").width($(this).width());
editor.refresh();
}
});
}); });

View File

@ -0,0 +1,13 @@
class AddCountersToMassBuild < ActiveRecord::Migration
def up
add_column :mass_builds, :success_count, :integer, :default => 0, :null => false
add_column :mass_builds, :build_canceled_count, :integer, :default => 0, :null => false
change_column :mass_builds, :new_core, :boolean, :default => true
end
def down
remove_column :mass_builds, :success_count
remove_column :mass_builds, :build_canceled_count
change_column :mass_builds, :new_core, :boolean, :default => false
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130128123151) do ActiveRecord::Schema.define(:version => 20130129145833) do
create_table "activity_feeds", :force => true do |t| create_table "activity_feeds", :force => true do |t|
t.integer "user_id", :null => false t.integer "user_id", :null => false
@ -266,7 +266,9 @@ ActiveRecord::Schema.define(:version => 20130128123151) do
t.text "projects_list" t.text "projects_list"
t.integer "missed_projects_count", :default => 0, :null => false t.integer "missed_projects_count", :default => 0, :null => false
t.text "missed_projects_list" t.text "missed_projects_list"
t.boolean "new_core", :default => false t.boolean "new_core", :default => true
t.integer "success_count", :default => 0, :null => false
t.integer "build_canceled_count", :default => 0, :null => false
end end
create_table "platforms", :force => true do |t| create_table "platforms", :force => true do |t|

View File

@ -27,13 +27,13 @@ Capistrano::Configuration.instance(:must_exist).load do
def start_workers def start_workers
queue = [ queue = [
:publish_observer,
:rpm_worker_observer,
:iso_worker_observer,
:fork_import, :fork_import,
:hook, :hook,
:clone_build, :clone_build,
:notification, :notification
:iso_worker_observer,
:rpm_worker_observer,
:publish_observer
].join(',') ].join(',')
run "cd #{fetch :current_path} && COUNT=#{workers_count} QUEUE=#{queue} #{rails_env} BACKGROUND=yes bundle exec rake resque:workers" run "cd #{fetch :current_path} && COUNT=#{workers_count} QUEUE=#{queue} #{rails_env} BACKGROUND=yes bundle exec rake resque:workers"
end end

View File

@ -96,6 +96,22 @@ describe PullRequest do
@wrong_pull.save @wrong_pull.save
@project.pull_requests.joins(:issue).where(:issues => {:title => @wrong_pull.title}).count.should == 0 @project.pull_requests.joins(:issue).where(:issues => {:title => @wrong_pull.title}).count.should == 0
end end
it "should create pull with tag" do
system("cd #{@project.path} && git tag 4.7.5.3 $(git rev-parse #{@pull.from_ref})") # TODO REDO through grit
@pull = @project.pull_requests.new(:issue_attributes => {:title => 'tag', :body => 'testing'})
@pull.issue.user, @pull.issue.project = @user, @pull.to_project
@pull.to_ref = 'master'
@pull.from_project, @pull.from_ref = @project, '4.7.5.3'
@pull.save
@project.pull_requests.joins(:issue).where(:issues => {:title => @pull.title}).count.should == 1
end
it "should close pull when deleting from branch" do
system("cd #{@project.path} && git branch -D #{@pull.from_branch}")
@pull.check
@project.pull_requests.joins(:issue).where(:issues => {:title => @pull.title, :status => 'closed'}).count.should == 1
end
end end
before do before do

View File

@ -5,7 +5,6 @@
.CodeMirror-scroll { .CodeMirror-scroll {
overflow: auto; overflow: auto;
height: 300px;
/* This is needed to prevent an IE[67] bug where the scrolled content /* This is needed to prevent an IE[67] bug where the scrolled content
is visible outside of the scrolling box. */ is visible outside of the scrolling box. */
position: relative; position: relative;