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
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
......
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