summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-14 19:43:48 +0100
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-16 13:01:34 +0100
commit0698c96d7dc472a0e7e74c290047a50eeddf27bb (patch)
treea3051c7ea9e98c6d4b6f50a63764e54fc8b3d04e
parent433e4a80efa50bdc3b588ae34c488b6982c2985d (diff)
downloadgitlab-ce-0698c96d7dc472a0e7e74c290047a50eeddf27bb.tar.gz
Remove duplicate code in Repository#*_names_contains
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--app/models/repository.rb23
1 files changed, 7 insertions, 16 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index f8c4cb1387b..f76b770e867 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -346,8 +346,8 @@ class Repository
end
end
- def branch_names_contains(sha)
- args = %W(#{Gitlab.config.git.bin_path} branch --contains #{sha})
+ def refs_contains_sha(ref_type, sha)
+ args = %W(#{Gitlab.config.git.bin_path} #{ref_type} --contains #{sha})
names = Gitlab::Popen.popen(args, path_to_repo).first
if names.respond_to?(:split)
@@ -363,21 +363,12 @@ class Repository
end
end
- def tag_names_contains(sha)
- args = %W(#{Gitlab.config.git.bin_path} tag --contains #{sha})
- names = Gitlab::Popen.popen(args, path_to_repo).first
-
- if names.respond_to?(:split)
- names = names.split("\n").map(&:strip)
-
- names.each do |name|
- name.slice! '* '
- end
+ def branch_names_contains(sha)
+ refs_contains_sha('branch', sha)
+ end
- names
- else
- []
- end
+ def tag_names_contains(sha)
+ refs_contains_sha('tag', sha)
end
def branches