Commit 0698c96d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Remove duplicate code in Repository#*_names_contains

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 433e4a80
...@@ -346,8 +346,8 @@ class Repository ...@@ -346,8 +346,8 @@ class Repository
end end
end end
def branch_names_contains(sha) def refs_contains_sha(ref_type, sha)
args = %W(#{Gitlab.config.git.bin_path} branch --contains #{sha}) args = %W(#{Gitlab.config.git.bin_path} #{ref_type} --contains #{sha})
names = Gitlab::Popen.popen(args, path_to_repo).first names = Gitlab::Popen.popen(args, path_to_repo).first
if names.respond_to?(:split) if names.respond_to?(:split)
...@@ -363,21 +363,12 @@ class Repository ...@@ -363,21 +363,12 @@ class Repository
end end
end end
def tag_names_contains(sha) def branch_names_contains(sha)
args = %W(#{Gitlab.config.git.bin_path} tag --contains #{sha}) refs_contains_sha('branch', 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 end
names def tag_names_contains(sha)
else refs_contains_sha('tag', sha)
[]
end
end end
def branches def branches
......
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