Class: GitPivotalTrackerIntegration::Command::Finish

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

Overview

The class that encapsulates finishing a Pivotal Tracker Story

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

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

Instance Method Details

#run(argument) ⇒ 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



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

def run(argument)
  GitPivotalTrackerIntegration::Util::Git.verify_uncommitted_changes!

  github = @configuration.github

  story = @configuration.story(@project)

  print "Creating PR on Github... \n"
  pr = github.pull_requests.create(
    user: GitPivotalTrackerIntegration::Util::Git.org_name,
    repo: GitPivotalTrackerIntegration::Util::Git.repo_name,
    base: GitPivotalTrackerIntegration::Util::Git.root_branch,
    head: GitPivotalTrackerIntegration::Util::Git.branch_name,
    title: "[Delivers ##{story.id}] #{story.name}",
    body: "#{story.name}\n#{story.description}\nPivotal Task: #{story.url}"
  )
  puts 'OK'
  print 'Finishing story on Pivotal Tracker... '
  story.update(
    :current_state => 'finished',
    :owned_by => GitPivotalTrackerIntegration::Util::Git.get_config('user.name')
  )
  puts 'OK'
end