summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-11-20 15:07:25 +0100
committerMatija Čupić <matteeyah@gmail.com>2018-12-08 19:28:56 +0100
commit24d682254a0ae68dfc605fc077c6a7610b97994a (patch)
tree2e9f98b014add9cfd2996aef4a9d8577ba7a9991 /app
parentd12bc3bfc47f9a4252e3f9eb60b1326eade7d3e5 (diff)
downloadgitlab-ce-24d682254a0ae68dfc605fc077c6a7610b97994a.tar.gz
Move Project#resolve_ref to Repository
Diffstat (limited to 'app')
-rw-r--r--app/models/project.rb17
-rw-r--r--app/models/repository.rb15
2 files changed, 16 insertions, 16 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index e9fa9cfabc9..2ba273c6f98 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1160,21 +1160,6 @@ class Project < ActiveRecord::Base
end
end
- def resolve_ref(ref)
- tag_exists = repository.tag_exists?(ref)
- branch_exists = repository.branch_exists?(ref)
-
- if tag_exists && branch_exists
- nil
- elsif tag_exists
- Gitlab::Git::TAG_REF_PREFIX + ref
- elsif branch_exists
- Gitlab::Git::BRANCH_REF_PREFIX + ref
- else
- ref
- end
- end
-
def root_ref?(branch)
repository.root_ref == branch
end
@@ -1752,7 +1737,7 @@ class Project < ActiveRecord::Base
end
def protected_for?(ref)
- resolved_ref = resolve_ref(ref)
+ resolved_ref = repository.resolve_ref(ref)
return false unless resolved_ref
ref_name = Gitlab::Git.ref_name(resolved_ref)
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 35dd120856d..221d01c5b44 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -182,6 +182,21 @@ class Repository
tags.find { |tag| tag.name == name }
end
+ def resolve_ref(ref)
+ tag_exists = tag_exists?(ref)
+ branch_exists = branch_exists?(ref)
+
+ if tag_exists && branch_exists
+ nil
+ elsif tag_exists
+ Gitlab::Git::TAG_REF_PREFIX + ref
+ elsif branch_exists
+ Gitlab::Git::BRANCH_REF_PREFIX + ref
+ else
+ ref
+ end
+ end
+
def add_branch(user, branch_name, ref)
branch = raw_repository.add_branch(branch_name, user: user, target: ref)