summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-09 13:39:52 +0100
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-09 13:39:52 +0100
commitbd54bf7a798c06751d464ac3af1fef0e7ee90ea6 (patch)
tree358622f7cad64b1c601a653fd2797f79cbb3c933
parenta353a87680dd9251183ddfd3fbf0a3e6ca8b5a03 (diff)
parent03b12ee5502e56b3cc9b14dfa92722f52ce41bce (diff)
downloadgitlab-ce-bd54bf7a798c06751d464ac3af1fef0e7ee90ea6.tar.gz
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce
-rw-r--r--CHANGELOG2
-rw-r--r--app/controllers/admin/application_settings_controller.rb1
-rw-r--r--app/models/application_setting.rb3
-rw-r--r--app/models/project.rb5
-rw-r--r--app/services/merge_requests/refresh_service.rb8
-rw-r--r--app/views/admin/application_settings/_form.html.haml9
-rw-r--r--config/initializers/1_settings.rb9
-rw-r--r--db/migrate/20151103133339_add_shared_runners_setting.rb5
-rw-r--r--db/schema.rb3
-rw-r--r--lib/gitlab/current_settings.rb3
-rw-r--r--spec/factories/ci/projects.rb2
-rw-r--r--spec/models/application_setting_spec.rb28
-rw-r--r--spec/services/ci/register_build_service_spec.rb4
-rw-r--r--spec/services/merge_requests/refresh_service_spec.rb19
14 files changed, 86 insertions, 15 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 3a75f50e9a2..19f288d0c7e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
Please view this file on the master branch, on stable branches it's out of date.
v 8.2.0 (unreleased)
+ - Fix bug where manually merged branches in a MR would end up with an empty diff (Stan Hu)
- Force update refs/merge-requests/X/head upon a push to the source branch of a merge request (Stan Hu)
- Improved performance of finding users by one of their Email addresses
- Improved performance of replacing references in comments
@@ -14,6 +15,7 @@ v 8.2.0 (unreleased)
- Use git follow flag for commits page when retrieve history for file or directory
- Show merge request CI status on merge requests index page
- Extend yml syntax for only and except to support specifying repository path
+ - Enable shared runners to all new projects
- Fix: 500 error returned if destroy request without HTTP referer (Kazuki Shimizu)
- Remove deprecated CI events from project settings page
- Use issue editor as cross reference comment author when issue is edited with a new mention.
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb
index 039f18f23e0..3d9c59050ff 100644
--- a/app/controllers/admin/application_settings_controller.rb
+++ b/app/controllers/admin/application_settings_controller.rb
@@ -57,6 +57,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:version_check_enabled,
:admin_notification_email,
:user_oauth_applications,
+ :shared_runners_enabled,
restricted_visibility_levels: [],
import_sources: []
)
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index 05430c2ee18..266045f7afa 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -87,7 +87,8 @@ class ApplicationSetting < ActiveRecord::Base
default_project_visibility: Settings.gitlab.default_projects_features['visibility_level'],
default_snippet_visibility: Settings.gitlab.default_projects_features['visibility_level'],
restricted_signup_domains: Settings.gitlab['restricted_signup_domains'],
- import_sources: ['github','bitbucket','gitlab','gitorious','google_code','fogbugz','git']
+ import_sources: ['github','bitbucket','gitlab','gitorious','google_code','fogbugz','git'],
+ shared_runners_enabled: Settings.gitlab_ci['shared_runners_enabled'],
)
end
diff --git a/app/models/project.rb b/app/models/project.rb
index 74b89aad499..57db7f9f0a4 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -37,6 +37,7 @@ class Project < ActiveRecord::Base
include Gitlab::ConfigHelper
include Gitlab::ShellAdapter
include Gitlab::VisibilityLevel
+ include Gitlab::CurrentSettings
include Referable
include Sortable
include AfterCommitQueue
@@ -775,7 +776,9 @@ class Project < ActiveRecord::Base
end
def ensure_gitlab_ci_project
- gitlab_ci_project || create_gitlab_ci_project
+ gitlab_ci_project || create_gitlab_ci_project(
+ shared_runners_enabled: current_application_settings.shared_runners_enabled
+ )
end
def enable_ci
diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb
index d68bc79ecc0..e180edb4bf3 100644
--- a/app/services/merge_requests/refresh_service.rb
+++ b/app/services/merge_requests/refresh_service.rb
@@ -7,17 +7,17 @@ module MergeRequests
@branch_name = Gitlab::Git.ref_name(ref)
find_new_commits
+ # Be sure to close outstanding MRs before reloading them to avoid generating an
+ # empty diff during a manual merge
+ close_merge_requests
reload_merge_requests
# Leave a system note if a branch was deleted/added
if branch_added? || branch_removed?
comment_mr_branch_presence_changed
- comment_mr_with_commits
- else
- comment_mr_with_commits
- close_merge_requests
end
+ comment_mr_with_commits
execute_mr_web_hooks
true
diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml
index 7a78526e09a..7253218c2e9 100644
--- a/app/views/admin/application_settings/_form.html.haml
+++ b/app/views/admin/application_settings/_form.html.haml
@@ -130,5 +130,14 @@
= f.text_area :help_page_text, class: 'form-control', rows: 4
.help-block Markdown enabled
+ %fieldset
+ %legend Continuous Integration
+ .form-group
+ .col-sm-offset-2.col-sm-10
+ .checkbox
+ = f.label :shared_runners_enabled do
+ = f.check_box :shared_runners_enabled
+ Enable shared runners for a new projects
+
.form-actions
= f.submit 'Save', class: 'btn btn-primary'
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index c189c88bdcb..64d73d7232d 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -181,10 +181,11 @@ Settings.gitlab['import_sources'] ||= ['github','bitbucket','gitlab','gitorious'
# CI
#
Settings['gitlab_ci'] ||= Settingslogic.new({})
-Settings.gitlab_ci['all_broken_builds'] = true if Settings.gitlab_ci['all_broken_builds'].nil?
-Settings.gitlab_ci['add_pusher'] = false if Settings.gitlab_ci['add_pusher'].nil?
-Settings.gitlab_ci['url'] ||= Settings.send(:build_gitlab_ci_url)
-Settings.gitlab_ci['builds_path'] = File.expand_path(Settings.gitlab_ci['builds_path'] || "builds/", Rails.root)
+Settings.gitlab_ci['shared_runners_enabled'] = true if Settings.gitlab_ci['shared_runners_enabled'].nil?
+Settings.gitlab_ci['all_broken_builds'] = true if Settings.gitlab_ci['all_broken_builds'].nil?
+Settings.gitlab_ci['add_pusher'] = false if Settings.gitlab_ci['add_pusher'].nil?
+Settings.gitlab_ci['url'] ||= Settings.send(:build_gitlab_ci_url)
+Settings.gitlab_ci['builds_path'] = File.expand_path(Settings.gitlab_ci['builds_path'] || "builds/", Rails.root)
#
# Reply by email
diff --git a/db/migrate/20151103133339_add_shared_runners_setting.rb b/db/migrate/20151103133339_add_shared_runners_setting.rb
new file mode 100644
index 00000000000..4231dfd5c2e
--- /dev/null
+++ b/db/migrate/20151103133339_add_shared_runners_setting.rb
@@ -0,0 +1,5 @@
+class AddSharedRunnersSetting < ActiveRecord::Migration
+ def up
+ add_column :application_settings, :shared_runners_enabled, :boolean, default: true, null: false
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 17d445a8baa..de896f2764b 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: 20151103001141) do
+ActiveRecord::Schema.define(version: 20151103133339) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -47,6 +47,7 @@ ActiveRecord::Schema.define(version: 20151103001141) do
t.text "import_sources"
t.text "help_page_text"
t.string "admin_notification_email"
+ t.boolean "shared_runners_enabled", default: true, null: false
end
create_table "audit_events", force: true do |t|
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb
index 0ea1b6a2f6f..cd84afa31d5 100644
--- a/lib/gitlab/current_settings.rb
+++ b/lib/gitlab/current_settings.rb
@@ -23,7 +23,8 @@ module Gitlab
restricted_visibility_levels: Settings.gitlab['restricted_visibility_levels'],
max_attachment_size: Settings.gitlab['max_attachment_size'],
session_expire_delay: Settings.gitlab['session_expire_delay'],
- import_sources: Settings.gitlab['import_sources']
+ import_sources: Settings.gitlab['import_sources'],
+ shared_runners_enabled: Settings.gitlab_ci['shared_runners_enabled'],
)
end
diff --git a/spec/factories/ci/projects.rb b/spec/factories/ci/projects.rb
index 111e1a82816..1183a190353 100644
--- a/spec/factories/ci/projects.rb
+++ b/spec/factories/ci/projects.rb
@@ -33,6 +33,8 @@ FactoryGirl.define do
gl_project factory: :empty_project
+ shared_runners_enabled false
+
factory :ci_project do
token 'iPWx6WM4lhHNedGfBpPJNP'
end
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb
index de0b2ef4cda..f01fe8bd398 100644
--- a/spec/models/application_setting_spec.rb
+++ b/spec/models/application_setting_spec.rb
@@ -28,11 +28,11 @@
require 'spec_helper'
describe ApplicationSetting, models: true do
- it { expect(ApplicationSetting.create_from_defaults).to be_valid }
+ let(:setting) { ApplicationSetting.create_from_defaults }
- context 'restricted signup domains' do
- let(:setting) { ApplicationSetting.create_from_defaults }
+ it { expect(setting).to be_valid }
+ context 'restricted signup domains' do
it 'set single domain' do
setting.restricted_signup_domains_raw = 'example.com'
expect(setting.restricted_signup_domains).to eq(['example.com'])
@@ -53,4 +53,26 @@ describe ApplicationSetting, models: true do
expect(setting.restricted_signup_domains).to eq(['example.com', '*.example.com'])
end
end
+
+ context 'shared runners' do
+ let(:gl_project) { create(:empty_project) }
+
+ before do
+ allow_any_instance_of(Project).to receive(:current_application_settings).and_return(setting)
+ end
+
+ subject { gl_project.ensure_gitlab_ci_project.shared_runners_enabled }
+
+ context 'enabled' do
+ before { setting.update_attributes(shared_runners_enabled: true) }
+
+ it { is_expected.to be_truthy }
+ end
+
+ context 'disabled' do
+ before { setting.update_attributes(shared_runners_enabled: false) }
+
+ it { is_expected.to be_falsey }
+ end
+ end
end
diff --git a/spec/services/ci/register_build_service_spec.rb b/spec/services/ci/register_build_service_spec.rb
index 781764627ac..b370dfbe113 100644
--- a/spec/services/ci/register_build_service_spec.rb
+++ b/spec/services/ci/register_build_service_spec.rb
@@ -70,6 +70,10 @@ module Ci
end
context 'disallow shared runners' do
+ before do
+ gl_project.gitlab_ci_project.update(shared_runners_enabled: false)
+ end
+
context 'shared runner' do
let(:build) { service.execute(shared_runner) }
diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb
index 227ac995ec2..7ee4488521d 100644
--- a/spec/services/merge_requests/refresh_service_spec.rb
+++ b/spec/services/merge_requests/refresh_service_spec.rb
@@ -62,6 +62,25 @@ describe MergeRequests::RefreshService do
it { expect(@fork_merge_request.notes.last.note).to include('changed to merged') }
end
+ context 'manual merge of source branch' do
+ before do
+ # Merge master -> feature branch
+ author = { email: 'test@gitlab.com', time: Time.now, name: "Me" }
+ commit_options = { message: 'Test message', committer: author, author: author }
+ master_commit = @project.repository.commit('master')
+ @project.repository.merge(@user, master_commit.id, 'feature', commit_options)
+ commit = @project.repository.commit('feature')
+ service.new(@project, @user).execute(@oldrev, commit.id, 'refs/heads/feature')
+ reload_mrs
+ end
+
+ it { expect(@merge_request.notes.last.note).to include('changed to merged') }
+ it { expect(@merge_request).to be_merged }
+ it { expect(@merge_request.diffs.length).to be > 0 }
+ it { expect(@fork_merge_request).to be_merged }
+ it { expect(@fork_merge_request.notes.last.note).to include('changed to merged') }
+ end
+
context 'push to fork repo source branch' do
let(:refresh_service) { service.new(@fork_project, @user) }
before do