Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Bajao <ebajao@gitlab.com>2019-03-07 04:09:37 +0300
committerPatrick Bajao <ebajao@gitlab.com>2019-03-07 07:47:31 +0300
commit333097d7652a863f1d328e4c6b86be5e3b570bbf (patch)
tree6e0b63ca34171a1d28248d262716c1bdaa988f1a
parent20805bedfcb2de15a661c327d29b1305367d6167 (diff)
Allow protected branch creation for empty project
-rw-r--r--lib/gitlab/checks/branch_check.rb2
-rw-r--r--spec/lib/gitlab/checks/branch_check_spec.rb15
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/gitlab/checks/branch_check.rb b/lib/gitlab/checks/branch_check.rb
index bd305ace0a0..75b337a14cc 100644
--- a/lib/gitlab/checks/branch_check.rb
+++ b/lib/gitlab/checks/branch_check.rb
@@ -46,7 +46,7 @@ module Gitlab
end
end
- if creation? && protected_branch_creation_enabled?
+ if creation? && protected_branch_creation_enabled? && !project.empty_repo?
protected_branch_creation_checks
elsif deletion?
protected_branch_deletion_checks
diff --git a/spec/lib/gitlab/checks/branch_check_spec.rb b/spec/lib/gitlab/checks/branch_check_spec.rb
index f99fc639dbd..1a672f9d80a 100644
--- a/spec/lib/gitlab/checks/branch_check_spec.rb
+++ b/spec/lib/gitlab/checks/branch_check_spec.rb
@@ -116,6 +116,21 @@ describe Gitlab::Checks::BranchCheck do
.and_return(['branch'])
end
+ context "when repo is empty" do
+ let(:project) { create(:project, :empty_repo) }
+ let(:ref) { 'refs/heads/master' }
+
+ before do
+ allow(user_access)
+ .to receive(:can_push_to_branch?)
+ .and_return(true)
+ end
+
+ it 'allows branch creation' do
+ expect { subject.validate! }.not_to raise_error
+ end
+ end
+
context "newrev isn't in any protected branches" do
before do
allow(ProtectedBranch)