From 5772faf19bcd859c01da167d3c756a1a2e2b5f7f Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 16 Sep 2015 16:46:10 +0200 Subject: Fix projects edit --- app/views/ci/projects/edit.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/ci/projects/edit.html.haml b/app/views/ci/projects/edit.html.haml index 298007a6565..79e8fd3a295 100644 --- a/app/views/ci/projects/edit.html.haml +++ b/app/views/ci/projects/edit.html.haml @@ -1,6 +1,6 @@ - if @project.generated_yaml_config %p.alert.alert-danger - CI Jobs are deprecated now, you can #{link_to "download", dumped_yaml_project_path(@project)} + CI Jobs are deprecated now, you can #{link_to "download", dumped_yaml_ci_project(@project)} or %a.preview-yml{:href => "#yaml-content", "data-toggle" => "modal"} preview yaml file which is based on your old jobs. -- cgit v1.2.1 From 7348d34cfdb50c1cc3efa2debb093e8019752ac2 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 16 Sep 2015 16:46:19 +0200 Subject: Fix migrate tags statement --- lib/ci/migrate/tags.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ci/migrate/tags.rb b/lib/ci/migrate/tags.rb index f4114c698d2..125a535e9a9 100644 --- a/lib/ci/migrate/tags.rb +++ b/lib/ci/migrate/tags.rb @@ -40,7 +40,7 @@ module Ci tags = ActiveRecord::Base.connection.select_all( 'select ci_tags.name from ci_tags ' + 'join ci_taggings on ci_tags.id = ci_taggings.tag_id ' + - "where taggable_type = #{ActiveRecord::Base::sanitize(type)} and taggable_id = #{ActiveRecord::Base::sanitize(id)} and context = \"tags\"" + "where taggable_type = #{ActiveRecord::Base::sanitize(type)} and taggable_id = #{ActiveRecord::Base::sanitize(id)} and context = 'tags'" ) tags.map { |tag| tag['name'] } end -- cgit v1.2.1 From e01300ddb0f8a910ac34329a6dabe83b3cbdc69d Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 16 Sep 2015 16:46:26 +0200 Subject: Fix update_runner_info helper --- lib/ci/api/helpers.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ci/api/helpers.rb b/lib/ci/api/helpers.rb index 9197f917d73..e602cda81d6 100644 --- a/lib/ci/api/helpers.rb +++ b/lib/ci/api/helpers.rb @@ -1,6 +1,8 @@ module Ci module API module Helpers + UPDATE_RUNNER_EVERY = 60 + def authenticate_runners! forbidden! unless params[:token] == GitlabCi::REGISTRATION_TOKEN end -- cgit v1.2.1 From 1b2a1d0ddd39ecc530c64563d0083e1e255f7c1a Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 16 Sep 2015 16:48:54 +0200 Subject: Fix skipped svg --- public/ci/build-skipped.svg | 1 + 1 file changed, 1 insertion(+) create mode 100644 public/ci/build-skipped.svg diff --git a/public/ci/build-skipped.svg b/public/ci/build-skipped.svg new file mode 100644 index 00000000000..f15507188e0 --- /dev/null +++ b/public/ci/build-skipped.svg @@ -0,0 +1 @@ +buildbuildskippedskipped \ No newline at end of file -- cgit v1.2.1 From 912f470497129b0d8759b18700299e38535e7bec Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 16 Sep 2015 16:59:54 +0200 Subject: Fix ordering issue --- app/models/ci/project.rb | 2 +- ...20150916145038_add_index_for_committed_at_and_id.rb | 5 +++++ db/schema.rb | 3 ++- spec/models/ci/project_spec.rb | 18 ++++++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20150916145038_add_index_for_committed_at_and_id.rb diff --git a/app/models/ci/project.rb b/app/models/ci/project.rb index 2cf1783616f..cd2692246b7 100644 --- a/app/models/ci/project.rb +++ b/app/models/ci/project.rb @@ -33,7 +33,7 @@ module Ci belongs_to :gl_project, class_name: '::Project', foreign_key: :gitlab_id - has_many :commits, ->() { order(:committed_at) }, dependent: :destroy, class_name: 'Ci::Commit' + has_many :commits, ->() { order('CASE WHEN commits.committed_at IS NULL THEN 0 ELSE 1 END', :committed_at, :id) }, dependent: :destroy, class_name: 'Ci::Commit' has_many :builds, through: :commits, dependent: :destroy, class_name: 'Ci::Build' has_many :runner_projects, dependent: :destroy, class_name: 'Ci::RunnerProject' has_many :runners, through: :runner_projects, class_name: 'Ci::Runner' diff --git a/db/migrate/20150916145038_add_index_for_committed_at_and_id.rb b/db/migrate/20150916145038_add_index_for_committed_at_and_id.rb new file mode 100644 index 00000000000..78d9e5f61a1 --- /dev/null +++ b/db/migrate/20150916145038_add_index_for_committed_at_and_id.rb @@ -0,0 +1,5 @@ +class AddIndexForCommittedAtAndId < ActiveRecord::Migration + def change + add_index :ci_commits, [:project_id, :committed_at, :id] + end +end diff --git a/db/schema.rb b/db/schema.rb index 5fd764bf698..48314b8db6a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150914215247) do +ActiveRecord::Schema.define(version: 20150916145038) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -118,6 +118,7 @@ ActiveRecord::Schema.define(version: 20150914215247) do t.datetime "committed_at" end + add_index "ci_commits", ["project_id", "committed_at", "id"], name: "index_ci_commits_on_project_id_and_committed_at_and_id", using: :btree add_index "ci_commits", ["project_id", "committed_at"], name: "index_ci_commits_on_project_id_and_committed_at", using: :btree add_index "ci_commits", ["project_id", "sha"], name: "index_ci_commits_on_project_id_and_sha", using: :btree add_index "ci_commits", ["project_id"], name: "index_ci_commits_on_project_id", using: :btree diff --git a/spec/models/ci/project_spec.rb b/spec/models/ci/project_spec.rb index 1025868da6e..a6fd6f27942 100644 --- a/spec/models/ci/project_spec.rb +++ b/spec/models/ci/project_spec.rb @@ -61,6 +61,24 @@ describe Ci::Project do end end + describe 'ordered commits' do + let (:project) { FactoryGirl.create :ci_project } + + it 'returns ordered list of commits' do + commit1 = FactoryGirl.create :ci_commit, committed_at: 1.hour.ago, project: project + commit2 = FactoryGirl.create :ci_commit, committed_at: 2.hour.ago, project: project + project.commits.should == [commit2, commit1] + end + + it 'returns commits ordered by committed_at and id, with nulls last' do + commit1 = FactoryGirl.create :ci_commit, committed_at: 1.hour.ago, project: project + commit2 = FactoryGirl.create :ci_commit, committed_at: nil, project: project + commit3 = FactoryGirl.create :ci_commit, committed_at: 2.hour.ago, project: project + commit4 = FactoryGirl.create :ci_commit, committed_at: nil, project: project + project.commits.should == [commit2, commit4, commit3, commit1] + end + end + context :valid_project do let(:project) { FactoryGirl.create :ci_project } -- cgit v1.2.1 From 7ea48ec54689cc262cc036fa65234a231a39c7e8 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 16 Sep 2015 17:19:05 +0200 Subject: Fix CI tests --- app/models/ci/project.rb | 2 +- spec/models/ci/project_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/ci/project.rb b/app/models/ci/project.rb index cd2692246b7..ae901d4ccd0 100644 --- a/app/models/ci/project.rb +++ b/app/models/ci/project.rb @@ -33,7 +33,7 @@ module Ci belongs_to :gl_project, class_name: '::Project', foreign_key: :gitlab_id - has_many :commits, ->() { order('CASE WHEN commits.committed_at IS NULL THEN 0 ELSE 1 END', :committed_at, :id) }, dependent: :destroy, class_name: 'Ci::Commit' + has_many :commits, ->() { order('CASE WHEN ci_commits.committed_at IS NULL THEN 0 ELSE 1 END', :committed_at, :id) }, dependent: :destroy, class_name: 'Ci::Commit' has_many :builds, through: :commits, dependent: :destroy, class_name: 'Ci::Build' has_many :runner_projects, dependent: :destroy, class_name: 'Ci::RunnerProject' has_many :runners, through: :runner_projects, class_name: 'Ci::Runner' diff --git a/spec/models/ci/project_spec.rb b/spec/models/ci/project_spec.rb index a6fd6f27942..89dc906e845 100644 --- a/spec/models/ci/project_spec.rb +++ b/spec/models/ci/project_spec.rb @@ -67,7 +67,7 @@ describe Ci::Project do it 'returns ordered list of commits' do commit1 = FactoryGirl.create :ci_commit, committed_at: 1.hour.ago, project: project commit2 = FactoryGirl.create :ci_commit, committed_at: 2.hour.ago, project: project - project.commits.should == [commit2, commit1] + expect(project.commits).to eq([commit2, commit1]) end it 'returns commits ordered by committed_at and id, with nulls last' do @@ -75,7 +75,7 @@ describe Ci::Project do commit2 = FactoryGirl.create :ci_commit, committed_at: nil, project: project commit3 = FactoryGirl.create :ci_commit, committed_at: 2.hour.ago, project: project commit4 = FactoryGirl.create :ci_commit, committed_at: nil, project: project - project.commits.should == [commit2, commit4, commit3, commit1] + expect(project.commits).to eq([commit2, commit4, commit3, commit1]) end end -- cgit v1.2.1 From 2b20603f5a7e419defc4bd58d9fce63924c843d8 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 16 Sep 2015 17:30:15 +0200 Subject: Make rubocop happy --- spec/models/ci/project_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/ci/project_spec.rb b/spec/models/ci/project_spec.rb index 89dc906e845..261ea69f5b4 100644 --- a/spec/models/ci/project_spec.rb +++ b/spec/models/ci/project_spec.rb @@ -62,7 +62,7 @@ describe Ci::Project do end describe 'ordered commits' do - let (:project) { FactoryGirl.create :ci_project } + let(:project) { FactoryGirl.create :ci_project } it 'returns ordered list of commits' do commit1 = FactoryGirl.create :ci_commit, committed_at: 1.hour.ago, project: project -- cgit v1.2.1