summaryrefslogtreecommitdiff
path: root/app/models/repository.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/repository.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/repository.rb')
-rw-r--r--app/models/repository.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 35dd120856d..10635eb0cf4 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -182,6 +182,16 @@ class Repository
tags.find { |tag| tag.name == name }
end
+ def find_ref(ref)
+ if Gitlab::Git.tag_ref?(ref)
+ find_tag(Gitlab::Git.ref_name(ref))
+ elsif Gitlab::Git.branch_ref?(ref)
+ find_branch(Gitlab::Git.ref_name(ref))
+ else
+ nil
+ end
+ end
+
def add_branch(user, branch_name, ref)
branch = raw_repository.add_branch(branch_name, user: user, target: ref)