Class: Gerrit::Command::Push

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

Overview

Push one or more commits for review.

Instance Method Summary collapse

Methods inherited from Base

#initialize, #run

Methods included from Utils

camel_case, commit_hash?, map_in_parallel, snake_case

Constructor Details

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

Instance Method Details

#executeObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gerrit/command/push.rb', line 4

def execute
  # Sanity check: does this repository have a valid remote_url?
  # (this will raise an exception if that's not the case)
  remote_url = repo.remote_url

  # If an explicit ref is given, skip a bunch of the questions
  if commit_hash?(arguments[1]) || arguments[1] == 'HEAD'
    ref = arguments[1]
    reviewer_args = arguments[2..-1] || []
    target_branch = 'master'
    type = 'publish'
    topic = nil
  else
    ref = 'HEAD'
    reviewer_args = arguments[1..-1] || []
    target_branch = ask_target_branch
    type = ask_review_type
    topic = ask_topic
  end

  reviewers = extract_reviewers(reviewer_args)

  push_changes(remote_url, ref, reviewers, target_branch, type, topic)
end