Commit dca04bd9 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'bvl-allow-default-branch-as-branch-name' into 'master'

Allow the default branch as branch name

Closes #3670

See merge request gitlab-org/gitlab-ee!3154
parents 0e6f0bec 63186cd9
---
title: Always allow the default branch as a branch name
merge_request: 3154
author:
type: fixed
......@@ -185,6 +185,7 @@ module Gitlab
def branch_name_allowed_by_push_rule?(push_rule)
return true unless push_rule
return true if @branch_name.blank?
return true if @branch_name == @project.default_branch
push_rule.branch_name_allowed?(@branch_name)
end
......
......@@ -266,6 +266,15 @@ describe Gitlab::Checks::ChangeAccess do
expect { subject }.to raise_error(Gitlab::GitAccess::UnauthorizedError, "Branch name does not follow the pattern '^(w*)$'")
end
end
context 'when the default branch does not match the push rules' do
let(:push_rule) { create(:push_rule, branch_name_regex: 'not-master') }
let(:ref) { "refs/heads/#{project.default_branch}" }
it 'allows the default branch even if it does not match push rule' do
expect { subject }.not_to raise_error
end
end
end
context 'existing member rules' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment