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