Class: Gerrit::Command::Submit

Inherits:
Base
  • Object
show all
Defined in:
lib/gerrit/command/submit.rb

Overview

Display a list of submittable changes and ask the user which to submit.

Constant Summary collapse

DEFAULT_SEARCH_QUERY =

Default search query that assumes a change is submittable if there is at least one +1 for both Code-Review and Verified labels and no -1s.

%w[
  is:open
  label:Code-Review+1
  label:Verified+1
  NOT label:Code-Review-1
  NOT label:Verified-1
].join(' ')

Instance Method Summary collapse

Methods inherited from Base

#execute_command, from_arguments, #initialize, #run

Methods included from Utils

camel_case, commit_hash?, human_time, map_in_parallel, snake_case

Constructor Details

This class inherits a constructor from Gerrit::Command::Base

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gerrit/command/submit.rb', line 14

def execute
  list_query = config.fetch('submittable_changes', DEFAULT_SEARCH_QUERY)
  execute_command(['list', list_query])

  # This will return a cached result from Command::List
  changes = Gerrit::Command::List.find_changes(client, list_query)

  index = 0
  while index < 1 || index > changes.size
    range = changes.size == 1 ? '' : "(1 - #{changes.size})"
    index = ui.ask("Which change would you like to submit? #{range} ")
              .argument(:required)
              .read_int
  end

  submit_change(changes[index - 1])
end