Commit dfe7f57e authored by Matija Čupić's avatar Matija Čupić

Rename Repository#resolve_ref to expand_ref

parent 63da5190
......@@ -1739,12 +1739,13 @@ class Project < ActiveRecord::Base
def protected_for?(ref)
return false if ref.nil? || repository.ambiguous_ref?(ref)
resolved_ref = repository.resolve_ref(ref)
ref_name = if resolved_ref == ref
Gitlab::Git.ref_name(resolved_ref)
else
ref
end
if Gitlab::Git.branch_ref?(ref) || Gitlab::Git.tag_ref?(ref)
resolved_ref = ref
ref_name = Gitlab::Git.ref_name(ref)
else
resolved_ref = repository.expand_ref(ref)
ref_name = ref
end
if Gitlab::Git.branch_ref?(resolved_ref)
ProtectedBranch.protected?(self, ref_name)
......
......@@ -186,13 +186,11 @@ class Repository
tag_exists?(ref) && branch_exists?(ref)
end
def resolve_ref(ref)
def expand_ref(ref)
if tag_exists?(ref)
Gitlab::Git::TAG_REF_PREFIX + ref
elsif branch_exists?(ref)
Gitlab::Git::BRANCH_REF_PREFIX + ref
elsif Gitlab::Git.tag_ref?(ref) || Gitlab::Git.branch_ref?(ref)
ref
end
end
......
......@@ -1032,16 +1032,16 @@ describe Repository do
end
end
describe '#resolve_ref' do
describe '#expand_ref' do
let(:ref) { 'ref' }
subject { repository.resolve_ref(ref) }
subject { repository.expand_ref(ref) }
context 'when ref is full ref' do
context 'when ref is not tag or branch name' do
let(:ref) { 'refs/heads/master' }
it 'returns the ref' do
is_expected.to eq(ref)
it 'returns nil' do
is_expected.to eq(nil)
end
end
......
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