From 421fa2880c186fe1a596d873e315a30bb9eef9c5 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 25 Jan 2013 14:11:15 +0600 Subject: [PATCH 1/8] [refs #765] add CodeMirror resizable ability --- app/assets/stylesheets/design/custom.scss | 9 +++++++++ app/views/projects/git/blobs/_editor.html.haml | 12 ++++++++++-- vendor/assets/stylesheets/codemirror.css | 1 - 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index 2ae68d0c2..4ee8835b2 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -1708,3 +1708,12 @@ table#myTable thead tr.search th form.button_to div input { margin-top: 2px; } +.file-editor { + margin-bottom: 10px; + margin-top: 10px; + max-width: 860px; +} + +.CodeMirror { + border: 1px solid #DDDDDD; +} \ No newline at end of file diff --git a/app/views/projects/git/blobs/_editor.html.haml b/app/views/projects/git/blobs/_editor.html.haml index 1298ff0c0..3cd15157b 100644 --- a/app/views/projects/git/blobs/_editor.html.haml +++ b/app/views/projects/git/blobs/_editor.html.haml @@ -5,7 +5,7 @@ .both = 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 = t("layout.enter_commit_message") @@ -23,4 +23,12 @@ lineNumbers: true, 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(); + } + }); + }); \ No newline at end of file diff --git a/vendor/assets/stylesheets/codemirror.css b/vendor/assets/stylesheets/codemirror.css index 89d08ffbe..d1f4d6c68 100644 --- a/vendor/assets/stylesheets/codemirror.css +++ b/vendor/assets/stylesheets/codemirror.css @@ -5,7 +5,6 @@ .CodeMirror-scroll { overflow: auto; - height: 300px; /* This is needed to prevent an IE[67] bug where the scrolled content is visible outside of the scrolling box. */ position: relative; From 7edcacee00895ebe49bb48b87b7e6748ecf2bbac Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 28 Jan 2013 20:31:08 +0600 Subject: [PATCH 2/8] [refs #719] fix errors with deleting refs --- app/models/pull_request.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/pull_request.rb b/app/models/pull_request.rb index ab0ddeb01..736797527 100644 --- a/app/models/pull_request.rb +++ b/app/models/pull_request.rb @@ -48,6 +48,11 @@ class PullRequest < ActiveRecord::Base end 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 new_status = case res when /Already up-to-date/ From 902438b7b545a43ee8d4b7f3088b4b799eec976a Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 28 Jan 2013 22:10:26 +0600 Subject: [PATCH 3/8] [refs #719] fixed errors with tags & history rewrite --- app/models/pull_request.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/models/pull_request.rb b/app/models/pull_request.rb index 736797527..a67af1587 100644 --- a/app/models/pull_request.rb +++ b/app/models/pull_request.rb @@ -176,16 +176,18 @@ class PullRequest < ActiveRecord::Base end Dir.chdir(path) do - system 'git', 'checkout', to_ref - system 'git', 'pull', 'origin', to_ref - if to_project_id == from_project_id - system 'git', 'checkout', from_ref - system 'git', 'pull', 'origin', from_ref - else - system 'git', 'fetch', 'head', "+#{from_ref}:#{from_branch}" + 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', '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}" end end - # TODO catch errors end def clean From dcea458198405765c76930877d04f31903b3a344 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 28 Jan 2013 22:42:00 +0600 Subject: [PATCH 4/8] [refs #719] add some specs --- spec/models/pull_request_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/models/pull_request_spec.rb b/spec/models/pull_request_spec.rb index 53841f81a..fc048b4ec 100644 --- a/spec/models/pull_request_spec.rb +++ b/spec/models/pull_request_spec.rb @@ -96,6 +96,22 @@ describe PullRequest do @wrong_pull.save @project.pull_requests.joins(:issue).where(:issues => {:title => @wrong_pull.title}).count.should == 0 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 before do From 2af919014daa69f448407fd36036ac72a48e44e4 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 29 Jan 2013 01:16:29 +0400 Subject: [PATCH 5/8] remove 'new_core' options for creating mass_builds --- app/controllers/platforms/mass_builds_controller.rb | 3 +-- app/models/mass_build.rb | 5 ++--- app/models/project.rb | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/controllers/platforms/mass_builds_controller.rb b/app/controllers/platforms/mass_builds_controller.rb index e9b866103..c12d82768 100644 --- a/app/controllers/platforms/mass_builds_controller.rb +++ b/app/controllers/platforms/mass_builds_controller.rb @@ -12,8 +12,7 @@ class Platforms::MassBuildsController < Platforms::BaseController def create mass_build = @platform.mass_builds.new(:arches => params[:arches], :auto_publish => params[:auto_publish] || false, - :projects_list => params[:projects_list], - :new_core => params[:new_core]) + :projects_list => params[:projects_list]) mass_build.user = current_user authorize! :create, mass_build diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index 7feb00fb9..3257ab6c8 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -7,7 +7,7 @@ class MassBuild < ActiveRecord::Base scope :outdated, where('created_at < ?', Time.now + 1.day - BuildList::MAX_LIVE_TIME) 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_inclusion_of :auto_publish, :in => [true, false] @@ -38,7 +38,7 @@ class MassBuild < ActiveRecord::Base return if self.reload.stop_build arches_list.each do |arch| 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 rescue RuntimeError, Exception end @@ -47,7 +47,6 @@ class MassBuild < ActiveRecord::Base list = (missed_projects_list || '') << "#{name}\n" update_column :missed_projects_list, list end - sleep 1 unless new_core end end later :build_all, :queue => :clone_build diff --git a/app/models/project.rb b/app/models/project.rb index 404347b00..b9a795d45 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -130,7 +130,7 @@ class Project < ActiveRecord::Base #path #share by NFS 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) # If main does not exist, will connect only project platform repository # If project platform repository is main, only main will be connect @@ -151,7 +151,6 @@ class Project < ActiveRecord::Base bl.priority = priority bl.mass_build_id = mass_build_id bl.save_to_repository_id = repository_id - bl.new_core = new_core end build_list.save end From 5fefb1f1da64e50785d451c654faf73c22df32f4 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 29 Jan 2013 01:59:56 +0400 Subject: [PATCH 6/8] Update lib/recipes/resque.rb --- lib/recipes/resque.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/recipes/resque.rb b/lib/recipes/resque.rb index 646d51caa..585df5c6b 100644 --- a/lib/recipes/resque.rb +++ b/lib/recipes/resque.rb @@ -27,13 +27,13 @@ Capistrano::Configuration.instance(:must_exist).load do def start_workers queue = [ + :publish_observer, + :rpm_worker_observer, + :iso_worker_observer, :fork_import, :hook, :clone_build, - :notification, - :iso_worker_observer, - :rpm_worker_observer, - :publish_observer + :notification ].join(',') run "cd #{fetch :current_path} && COUNT=#{workers_count} QUEUE=#{queue} #{rails_env} BACKGROUND=yes bundle exec rake resque:workers" end From 1f6b9dacc551721cbada841c3a469e13b41d1e74 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 29 Jan 2013 21:20:28 +0600 Subject: [PATCH 7/8] [refs #819] add two additional counters to mass builds --- app/models/mass_build.rb | 4 +++- db/schema.rb | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index 3257ab6c8..222cbb4d9 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -21,7 +21,9 @@ class MassBuild < ActiveRecord::Base :build_pending, :build_started, :build_publish, - :build_error + :build_error, + :success, + :build_canceled ] def build_all diff --git a/db/schema.rb b/db/schema.rb index 2a61dd880..922cffb18 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130119125710) do +ActiveRecord::Schema.define(:version => 20130129145833) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false @@ -267,6 +267,8 @@ ActiveRecord::Schema.define(:version => 20130119125710) do t.integer "missed_projects_count", :default => 0, :null => false t.text "missed_projects_list" t.boolean "new_core", :default => false + t.integer "success_count", :default => 0, :null => false + t.integer "build_canceled_count", :default => 0, :null => false end create_table "platforms", :force => true do |t| From 4bb3f268779200c35c2118c52b9221bb23214d0e Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 29 Jan 2013 23:48:43 +0600 Subject: [PATCH 8/8] [refs #819] migration --- .../20130129145833_add_counters_to_mass_build.rb | 13 +++++++++++++ db/schema.rb | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20130129145833_add_counters_to_mass_build.rb diff --git a/db/migrate/20130129145833_add_counters_to_mass_build.rb b/db/migrate/20130129145833_add_counters_to_mass_build.rb new file mode 100644 index 000000000..f67ca4214 --- /dev/null +++ b/db/migrate/20130129145833_add_counters_to_mass_build.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 922cffb18..d2a3da177 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -266,7 +266,7 @@ ActiveRecord::Schema.define(:version => 20130129145833) do t.text "projects_list" t.integer "missed_projects_count", :default => 0, :null => false 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