Class: GitPivotalTrackerIntegration::Command::Start
- Defined in:
- lib/git-pivotal-tracker-integration/command/start.rb
Overview
The class that encapsulates starting a Pivotal Tracker Story
Constant Summary
Constants inherited from Base
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, #finish_toggle, #initialize, #logger_filename, #parameters, #seconds_spent, #start_logging
Constructor Details
This class inherits a constructor from GitPivotalTrackerIntegration::Command::Base
Instance Method Details
#check_branch ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/git-pivotal-tracker-integration/command/start.rb', line 64 def check_branch current_branch = GitPivotalTrackerIntegration::Util::Git.branch_name # suggested_branch = (GitPivotalTrackerIntegration::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_chage_branch = ask("Your currently checked out branch is '#{current_branch}'. Do you want to checkout '#{suggested_branch}' before starting?(Y/n)") if should_chage_branch != "n" $LOG.debug("Checking out branch '#{suggested_branch}'") print "Checking out branch '#{suggested_branch}'...\n\n" $LOG.debug(GitPivotalTrackerIntegration::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
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 62 |
# File 'lib/git-pivotal-tracker-integration/command/start.rb', line 36 def run(args) my_projects = PivotalTracker::Project.all filter = args[0] $LOG.debug("#{self.class} in project:#{@project.name} pwd:#{pwd} branch:#{GitPivotalTrackerIntegration::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 = GitPivotalTrackerIntegration::Util::Story.select_story @project, filter end if story.nil? abort "There are no available stories." end if story.story_type == "feature" && story.estimate < 0 estimate_story(story) end $LOG.debug("story:#{story.name}") 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__), !OS.windows? ? 'prepare-commit-msg.sh' : 'prepare-commit-msg-win.sh' ) start_on_tracker story end |