Class: GitPivotalTracker::Story

Inherits:
Base
  • Object
show all
Defined in:
lib/git_pivotal_tracker/story.rb

Direct Known Subclasses

Bug, Chore, Feature

Constant Summary

Constants inherited from Base

Base::GIT_DIR

Instance Attribute Summary

Attributes inherited from Base

#options, #repository

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from GitPivotalTracker::Base

Instance Method Details

#run!Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/git_pivotal_tracker/story.rb', line 4

def run!
  return 1 if super

  puts "Retrieving latest #{type} from Pivotal Tracker"

  unless story = fetch_story
    puts "No #{type} available!"
    return 1
  end

  puts "URL:   #{story.url}"
  puts "Story: #{story.name}"

  print "Enter branch name [#{branch_suffix story}]: "
  suffix = gets.chomp
  suffix = branch_suffix(story) if suffix == ""

  branch = "#{story.story_type}-#{story.id}-#{suffix}"
  puts "Checking out a new branch '#{branch}'"
  log repository.git.checkout({:b => true, :raise => true}, branch)

  puts "Updating #{type} status in Pivotal Tracker..."
  if story.update(:owned_by => options[:full_name], :current_state => :started)
    puts "Success"
    return 0
  else
    puts "Unable to mark #{type} as started"
    return 1
  end
end

#typeObject



35
36
37
# File 'lib/git_pivotal_tracker/story.rb', line 35

def type
  self.class.name.downcase.split(/::/).last
end