Class: PivotalIntegration::Command::Finish

Inherits:
Base
  • Object
show all
Defined in:
lib/pivotal-integration/command/finish.rb

Overview

The class that encapsulates finishing a Pivotal Tracker Story

Instance Method Summary collapse

Methods inherited from Base

desc, #initialize, #story

Constructor Details

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

Instance Method Details

#run(*arguments) ⇒ void

This method returns an undefined value.

Finishes a Pivotal Tracker story by doing the following steps:

  • Check that the pending merge will be trivial

  • Merge the development branch into the root branch

  • Delete the development branch

  • Push changes to remote



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/pivotal-integration/command/finish.rb', line 29

def run(*arguments)
  no_complete = @options.fetch(:no_complete, false)
  no_delete = @options.fetch(:no_delete, false)
  no_merge = @options.fetch(:no_merge, false)
  pull_request = @options.fetch(:pull_request, false) || PivotalIntegration::Util::Git.finish_mode == :pull_request

  if pull_request
    PivotalIntegration::Util::Git.push PivotalIntegration::Util::Git.branch_name
    PivotalIntegration::Util::Git.create_pull_request(@configuration.story)
    PivotalIntegration::Util::Story.mark(@configuration.story, :finished)
    return
  end

  unless no_merge
    PivotalIntegration::Util::Git.trivial_merge?
    PivotalIntegration::Util::Git.merge(@configuration.story, no_complete, no_delete)
  end

  PivotalIntegration::Util::Git.push PivotalIntegration::Util::Git.branch_name
end