diff options
author | Ash McKenzie <amckenzie@gitlab.com> | 2019-09-06 02:58:00 +0000 |
---|---|---|
committer | Ash McKenzie <amckenzie@gitlab.com> | 2019-09-06 02:58:00 +0000 |
commit | 428500186952519ae1ad335dc5c05364bf8563b4 (patch) | |
tree | b4a1574e87cd51c99f7313c29517c00af438d846 /lib | |
parent | 71ff2c13e8241a4c19cb902e6ab62d2fb99630d4 (diff) | |
parent | 582e075e9f51567a0f004e5b34ca099b09a72059 (diff) | |
download | gitlab-ce-428500186952519ae1ad335dc5c05364bf8563b4.tar.gz |
Merge branch 'add-label-push-opts' into 'master'
Support adding and removing labels w/ push opts
Closes #5942
See merge request gitlab-org/gitlab-ce!31831
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/push_options.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/gitlab/push_options.rb b/lib/gitlab/push_options.rb index 682edfc4259..a2296d265cd 100644 --- a/lib/gitlab/push_options.rb +++ b/lib/gitlab/push_options.rb @@ -7,10 +7,12 @@ module Gitlab keys: [ :create, :description, + :label, :merge_when_pipeline_succeeds, :remove_source_branch, :target, - :title + :title, + :unlabel ] }, ci: { @@ -18,6 +20,11 @@ module Gitlab } }).freeze + MULTI_VALUE_OPTIONS = [ + %w[merge_request label], + %w[merge_request unlabel] + ].freeze + NAMESPACE_ALIASES = HashWithIndifferentAccess.new({ mr: :merge_request }).freeze @@ -50,12 +57,22 @@ module Gitlab next if [namespace, key].any?(&:nil?) options[namespace] ||= HashWithIndifferentAccess.new - options[namespace][key] = value + + if option_multi_value?(namespace, key) + options[namespace][key] ||= HashWithIndifferentAccess.new(0) + options[namespace][key][value] += 1 + else + options[namespace][key] = value + end end options end + def option_multi_value?(namespace, key) + MULTI_VALUE_OPTIONS.any? { |arr| arr == [namespace, key] } + end + def parse_option(option) parts = OPTION_MATCHER.match(option) return unless parts |