class GitPivotalTrackerIntegration::Command::Start
The class that encapsulates starting a Pivotal Tracker Story
Public Instance Methods
run(filter)
click to toggle source
Starts a Pivotal Tracker story by doing the following steps:
-
Create a branch
-
Add default commit hook
-
Start
the story on Pivotal Tracker
@param [String, nil] filter a filter for selecting the story to start. This
filter can be either: * a story id * a story type (feature, bug, chore) * +nil+
@return [void]
# File lib/git-pivotal-tracker-integration/command/start.rb, line 36 def run(filter) story = GitPivotalTrackerIntegration::Util::Story.select_story @project, filter GitPivotalTrackerIntegration::Util::Story.pretty_print story development_branch_name = development_branch_name story GitPivotalTrackerIntegration::Util::Git.create_branch development_branch_name @configuration.story = story GitPivotalTrackerIntegration::Util::Git.add_hook 'prepare-commit-msg', File.join(File.dirname(__FILE__), 'prepare-commit-msg.sh') start_on_tracker story end
Private Instance Methods
development_branch_name(story)
click to toggle source
# File lib/git-pivotal-tracker-integration/command/start.rb, line 52 def development_branch_name(story) suggested = "#{story.id}-#{story.name.strip.gsub(/[^a-zA-Z0-9]/, '-').squeeze}" suggested = suggested.split("-")[0, 10].join("-") puts "suggested name: #{suggested}" user_choice = ask("Enter branch name (or enter to accept suggestion)").strip if (user_choice == '') branch_name = suggested else branch_name = "#{story.id}-" + user_choice.gsub(/[^a-zA-Z0-9]/, '-').squeeze end puts branch_name end
start_on_tracker(story)
click to toggle source
# File lib/git-pivotal-tracker-integration/command/start.rb, line 66 def start_on_tracker(story) print 'Starting story on Pivotal Tracker... ' story.update( :current_state => 'started', :owned_by => GitPivotalTrackerIntegration::Util::Git.get_config('user.name') ) puts 'OK' end