Allow protected branch creation for empty project
This commit is contained in:
parent
20805bedfc
commit
333097d765
2 changed files with 16 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue