summaryrefslogtreecommitdiff
path: root/app/models/project.rb
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-11-15 22:54:21 +0100
committerMatija Čupić <matteeyah@gmail.com>2018-12-08 19:28:34 +0100
commit855e7c32b9f3541fec085726d338802c8ca9b9f4 (patch)
tree83794f5482e6b36e1f779788eb2d2c0fc24e51c0 /app/models/project.rb
parentce14c20a82af697b927666123443a25f19dab2ae (diff)
downloadgitlab-ce-855e7c32b9f3541fec085726d338802c8ca9b9f4.tar.gz
Use Gitlab::Git::Ref in Project#resolve_ref
Reworks Project#resolve_ref to return Gitlab::Git::Branch, Gitlab::Git::Tag or raise an AmbiguousRef error.
Diffstat (limited to 'app/models/project.rb')
-rw-r--r--app/models/project.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 61840c972ee..6893f76dda9 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1168,11 +1168,11 @@ class Project < ActiveRecord::Base
if tag_exists && branch_exists
raise AmbiguousRef
elsif tag_exists
- Gitlab::Git::TAG_REF_PREFIX + ref
+ repository.find_tag(ref)
elsif branch_exists
- Gitlab::Git::BRANCH_REF_PREFIX + ref
+ repository.find_branch(ref)
else
- ref
+ repository.find_ref(ref)
end
end
@@ -1753,8 +1753,9 @@ class Project < ActiveRecord::Base
end
def protected_for?(ref)
- full_ref = resolve_ref(ref)
- ref_name = Gitlab::Git.ref_name(full_ref)
+ resolved_ref = resolve_ref(ref)
+ full_ref = resolved_ref.full_ref
+ ref_name = resolved_ref.name
if Gitlab::Git.branch_ref?(full_ref)
ProtectedBranch.protected?(self, ref_name)