summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2019-09-09 04:07:46 +0000
committerAsh McKenzie <amckenzie@gitlab.com>2019-09-09 04:07:46 +0000
commit154f474bca2c432cdd2778de111a94191b537aa4 (patch)
tree8794c9c1ef4576a9e6855bda2dd9932a1fb9fbd0 /lib
parent1eeee0dd246f271f2eca140505758298bc74c930 (diff)
parent4aa4449ef5109eb0784f63fe1b7a3fc15bea8497 (diff)
downloadgitlab-ce-154f474bca2c432cdd2778de111a94191b537aa4.tar.gz
Merge branch 'reduce-parse-options-complexity' into 'master'
Refactor parse_options() in push_options.rb Closes #67091 See merge request gitlab-org/gitlab-ce!32756
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/push_options.rb20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/gitlab/push_options.rb b/lib/gitlab/push_options.rb
index a2296d265cd..93c0f3132d0 100644
--- a/lib/gitlab/push_options.rb
+++ b/lib/gitlab/push_options.rb
@@ -56,19 +56,23 @@ module Gitlab
next if [namespace, key].any?(&:nil?)
- options[namespace] ||= HashWithIndifferentAccess.new
-
- if option_multi_value?(namespace, key)
- options[namespace][key] ||= HashWithIndifferentAccess.new(0)
- options[namespace][key][value] += 1
- else
- options[namespace][key] = value
- end
+ store_option_info(options, namespace, key, value)
end
options
end
+ def store_option_info(options, namespace, key, value)
+ options[namespace] ||= HashWithIndifferentAccess.new
+
+ if option_multi_value?(namespace, key)
+ options[namespace][key] ||= HashWithIndifferentAccess.new(0)
+ options[namespace][key][value] += 1
+ else
+ options[namespace][key] = value
+ end
+ end
+
def option_multi_value?(namespace, key)
MULTI_VALUE_OPTIONS.any? { |arr| arr == [namespace, key] }
end