Class: Gitlab::PushOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/push_options.rb

Constant Summary collapse

VALID_OPTIONS =
HashWithIndifferentAccess.new({
  merge_request: {
    keys: [
      :assign,
      :create,
      :description,
      :draft,
      :label,
      :merge_when_pipeline_succeeds,
      :milestone,
      :remove_source_branch,
      :squash,
      :target,
      :target_project,
      :title,
      :unassign,
      :unlabel
    ]
  },
  ci: {
    keys: [:skip, :variable]
  },
  integrations: {
    keys: [:skip_ci]
  },
  secret_detection: {
    keys: [:skip_all]
  },
  secret_push_protection: {
    keys: [:skip_all]
  }
}).freeze
MULTI_VALUE_OPTIONS =
[
  %w[ci variable],
  %w[merge_request label],
  %w[merge_request unlabel],
  %w[merge_request assign],
  %w[merge_request unassign]
].freeze
NAMESPACE_ALIASES =
HashWithIndifferentAccess.new({
  mr: :merge_request
}).freeze
OPTION_MATCHER =
Gitlab::UntrustedRegexp.new('(?<namespace>[^\.]+)\.(?<key>[^=]+)=?(?<value>.*)')
CI_SKIP =
'ci.skip'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = []) ⇒ PushOptions

Returns a new instance of PushOptions.



56
57
58
# File 'lib/gitlab/push_options.rb', line 56

def initialize(options = [])
  @options = parse_options(options)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



54
55
56
# File 'lib/gitlab/push_options.rb', line 54

def options
  @options
end

Instance Method Details

#as_json(*_args) ⇒ Object

Allow #to_json serialization



65
66
67
# File 'lib/gitlab/push_options.rb', line 65

def as_json(*_args)
  options
end

#getObject



60
61
62
# File 'lib/gitlab/push_options.rb', line 60

def get(...)
  options.dig(...)
end