Skip to content
Snippets Groups Projects
Commit 1c0def2a authored by Maxim Rydkin's avatar Maxim Rydkin
Browse files

replace `is_default_branch?` with `default_branch?`

parent 622c912d
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -30,7 +30,7 @@ class GitPushService < BaseService
@project.repository.after_create_branch
 
# Re-find the pushed commits.
if is_default_branch?
if default_branch?
# Initial push to the default branch. Take the full history of that branch as "newly pushed".
process_default_branch
else
Loading
Loading
@@ -50,7 +50,7 @@ class GitPushService < BaseService
 
# Update the bare repositories info/attributes file using the contents of the default branches
# .gitattributes file
update_gitattributes if is_default_branch?
update_gitattributes if default_branch?
end
 
execute_related_hooks
Loading
Loading
@@ -66,7 +66,7 @@ class GitPushService < BaseService
end
 
def update_caches
if is_default_branch?
if default_branch?
if push_to_new_branch?
# If this is the initial push into the default branch, the file type caches
# will already be reset as a result of `Project#change_head`.
Loading
Loading
@@ -108,7 +108,7 @@ class GitPushService < BaseService
 
# Schedules processing of commit messages.
def process_commit_messages
default = is_default_branch?
default = default_branch?
 
@push_commits.last(PROCESS_COMMIT_LIMIT).each do |commit|
if commit.matches_cross_reference_regex?
Loading
Loading
@@ -202,7 +202,7 @@ class GitPushService < BaseService
Gitlab::Git.branch_ref?(params[:ref])
end
 
def is_default_branch?
def default_branch?
Gitlab::Git.branch_ref?(params[:ref]) &&
(Gitlab::Git.ref_name(params[:ref]) == project.default_branch || project.default_branch.nil?)
end
Loading
Loading
Loading
Loading
@@ -617,7 +617,7 @@ describe GitPushService, services: true do
 
context 'on the default branch' do
before do
allow(service).to receive(:is_default_branch?).and_return(true)
allow(service).to receive(:default_branch?).and_return(true)
end
 
it 'flushes the caches of any special files that have been changed' do
Loading
Loading
@@ -638,7 +638,7 @@ describe GitPushService, services: true do
 
context 'on a non-default branch' do
before do
allow(service).to receive(:is_default_branch?).and_return(false)
allow(service).to receive(:default_branch?).and_return(false)
end
 
it 'does not flush any conditional caches' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment