BigW Consortium Gitlab

Merge branch 'sh-fix-root-ref-repository' into 'master'

Gracefully handle case when repository's root ref does not exist Closes #40615 See merge request gitlab-org/gitlab-ce!15678 Signed-off-by: 's avatarRémy Coutable <remy@rymai.me>
parent 3141105e
---
title: "Gracefully handle case when repository's root ref does not exist"
merge_request:
author:
type: fixed
......@@ -1222,6 +1222,8 @@ module Gitlab
end
def git_merged_branch_names(branch_names = [])
return [] unless root_ref
lines = run_git(['branch', '--merged', root_ref] + branch_names)
.first.lines
......
......@@ -1217,6 +1217,16 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
end
context 'when no root ref is available' do
it 'returns empty list' do
project = create(:project, :empty_repo)
names = project.repository.merged_branch_names(%w[feature])
expect(names).to be_empty
end
end
context 'when no branch names are specified' do
it 'returns all merged branch names' do
names = repository.merged_branch_names
......
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