Remove duplicate code in Repository#*_names_contains
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
433e4a80ef
commit
0698c96d7d
|
@ -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
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def branch_names_contains(sha)
|
||||||
|
refs_contains_sha('branch', sha)
|
||||||
|
end
|
||||||
|
|
||||||
def tag_names_contains(sha)
|
def tag_names_contains(sha)
|
||||||
args = %W(#{Gitlab.config.git.bin_path} tag --contains #{sha})
|
refs_contains_sha('tag', 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
|
|
||||||
|
|
||||||
names
|
|
||||||
else
|
|
||||||
[]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def branches
|
def branches
|
||||||
|
|
Loading…
Reference in New Issue