summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-16 13:05:49 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-11-16 13:05:49 +0000
commit1328e4b504773ff98d716fd561dbc50fd7652a36 (patch)
treed8889a1e09412b77b21e841b1262bd6589970cf2 /app/models
parentb736a7b15e0a113da72541b8d4f60bd6e0adfb35 (diff)
parentc9f2f2a4838f9aa49782acdb7cfad75d06f31ac2 (diff)
downloadgitlab-ce-1328e4b504773ff98d716fd561dbc50fd7652a36.tar.gz
Merge branch 'refactor-duplication' into 'master'
Remove some code duplication * remove duplicate code in uploaders * remove duplicate code in NotificationHelper * remove duplicate code in Repository Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> See merge request !1800
Diffstat (limited to 'app/models')
-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