Class: Octopolo::Scripts::Deployable

Inherits:
Object
  • Object
show all
Includes:
CLIWrapper, ConfigWrapper
Defined in:
lib/octopolo/scripts/deployable.rb

Instance Attribute Summary collapse

Attributes included from ConfigWrapper

#config

Attributes included from CLIWrapper

#cli

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pull_request_id = nil, options = {}) ⇒ Deployable

Returns a new instance of Deployable.



21
22
23
24
# File 'lib/octopolo/scripts/deployable.rb', line 21

def initialize(pull_request_id=nil, options={})
  @pull_request_id = pull_request_id
  @force = options[:force]
end

Instance Attribute Details

#pull_request_idObject

Returns the value of attribute pull_request_id.



11
12
13
# File 'lib/octopolo/scripts/deployable.rb', line 11

def pull_request_id
  @pull_request_id
end

Class Method Details

.deployable_labelObject



17
18
19
# File 'lib/octopolo/scripts/deployable.rb', line 17

def self.deployable_label
  Octopolo::GitHub::Label.new(name: "deployable", color: "428BCA")
end

.execute(pull_request_id = nil, options = {}) ⇒ Object



13
14
15
# File 'lib/octopolo/scripts/deployable.rb', line 13

def self.execute(pull_request_id=nil, options={})
  new(pull_request_id, options).execute
end

Instance Method Details

#executeObject

Public: Perform the script



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/octopolo/scripts/deployable.rb', line 27

def execute
  if (!self.pull_request_id)
    current = GitHub::PullRequest.current
    self.pull_request_id = current.number if current
  end
  self.pull_request_id ||= cli.prompt("Pull Request ID: ")
  GitHub.connect do
    unless deployable? || @force
      CLI.say 'Pull request status checks have not passed. Cannot be marked deployable.'
      exit!
    end

    merge_result = merge
    add_deployable_label if config.deployable_label && merge_result
  end
end