Class: GitPivotalTrackerIntegration::Command::Start
- Defined in:
- lib/git-pivotal-tracker-integration/command/start.rb
Overview
The class that encapsulates starting a Pivotal Tracker Story
Instance Method Summary collapse
- #check_branch ⇒ Object
-
#run(args) ⇒ void
Starts a Pivotal Tracker story by doing the following steps: * Create a branch * Add default commit hook * Start the story on Pivotal Tracker.
Methods inherited from Base
#check_version, #create_backlog_bug_story, #create_backlog_feature_story, #create_icebox_bug_story, #create_icebox_feature_story, #create_story, #estimated_seconds, #initialize, #logger_filename, #seconds_spent, #start_logging
Constructor Details
This class inherits a constructor from GitPivotalTrackerIntegration::Command::Base
Instance Method Details
#check_branch ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/git-pivotal-tracker-integration/command/start.rb', line 63 def check_branch current_branch = Util::Git.branch_name # suggested_branch = (Util::Shell.exec "git config --get git-pivotal-tracker-integration.feature-root 2>/dev/null", false).chomp suggested_branch = 'develop' if !suggested_branch.nil? && suggested_branch.length !=0 && current_branch != suggested_branch $LOG.warn("Currently checked out branch is '#{current_branch}'.") should_change_branch = ask("Your currently checked out branch is '#{current_branch}'. Do you want to checkout '#{suggested_branch}' before starting?(Y/n)") if should_change_branch != "n" $LOG.debug("Checking out branch '#{suggested_branch}'") print "Checking out branch '#{suggested_branch}'...\n\n" $LOG.debug(Util::Shell.exec "git checkout --quiet #{suggested_branch}") end end end |
#run(args) ⇒ void
This method returns an undefined value.
Starts a Pivotal Tracker story by doing the following steps:
-
Create a branch
-
Add default commit hook
-
Start the story on Pivotal Tracker
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/git-pivotal-tracker-integration/command/start.rb', line 33 def run(args) filter = args[0] $LOG.debug("#{self.class} in project:#{@project.name} pwd:#{pwd} branch:#{Util::Git.branch_name} args:#{filter}") self.check_branch story = nil if (!args.nil? && args.any?{|arg| arg.include?("-n")}) story = self.create_story(args) else story = Util::Story.select_story @project, filter end abort "There are no available stories." if story.nil? if story.estimate.nil? if @project.bugs_and_chores_are_estimatable || story.story_type == 'feature' story.estimate = estimate_story story.save end end $LOG.debug("story:#{story.name}") Util::Story.pretty_print story Util::Git.create_branch feature_branch(story) @configuration.story = story Util::Git.add_hook 'prepare-commit-msg', File.join(File.dirname(__FILE__), !OS.windows? ? 'prepare-commit-msg.sh' : 'prepare-commit-msg-win.sh' ) start_on_tracker story end |