Class: GitPivotalTrackerIntegration::Command::Deliver
- Defined in:
- lib/git-pivotal-tracker-integration/command/deliver.rb
Overview
The class that encapsulates starting a Pivotal Tracker Story
Instance Method Summary collapse
- #check_branch ⇒ Object
-
#run(filter) ⇒ 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
100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/git-pivotal-tracker-integration/command/deliver.rb', line 100 def check_branch current_branch = Util::Git.branch_name suggested_branch = "develop" if !suggested_branch.nil? && suggested_branch.length !=0 && current_branch != suggested_branch should_change_branch = ask("Your currently checked out branch is '#{current_branch}'. \n\n Do you want to checkout '#{suggested_branch}' before starting?(Y/n)") if should_change_branch != "n" print "Checking out branch '#{suggested_branch}'...\n\n" Util::Shell.exec "git checkout #{suggested_branch}" Util::Shell.exec 'git pull' end end end |
#run(filter) ⇒ 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
32 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/git-pivotal-tracker-integration/command/deliver.rb', line 32 def run(filter) $LOG.debug("#{self.class} in project:#{@project.name} pwd:#{pwd} branch:#{Util::Git.branch_name}") self.check_branch story = Util::Story.select_release @project $LOG.debug("Release Story:#{story.name}") #sort_for_deliver story Util::Story.pretty_print story current_branch = Util::Git.branch_name if current_branch == 'develop' puts "Merging from orgin develop..." Util::Shell.exec "git pull" # checkout QA branch # Merge develop into QA Util::Shell.exec "git checkout QA" Util::Shell.exec "git reset --hard origin/QA" Util::Shell.exec "git pull" if (Util::Shell.exec "git merge -s recursive --strategy-option theirs develop") puts "Merged 'develop' in to 'QA'" else abort "FAILED to merge 'develop' in to 'QA'" end else # we might be on a feature branch. So create a seperate branch for qa. qa_current_branch = "qa-#{current_branch}" print "Creating and Checking out new qa branch #{qa_current_branch}" Util::Shell.exec "git checkout --quiet -b #{qa_current_branch}" Util::Shell.exec "git push -u origin #{qa_current_branch}" end # retrieve build number from story name build_number = story.name.slice(1..-1) working_directory = pwd puts "Story Name: #{story.name}" puts "Build Number: #{build_number}" puts "Working Directory: #{working_directory}*" puts "" if (OS.mac? && @platform.downcase == "ios") project_directory = @configuration.xcode_project_path project_directory ||= ((Util::Shell.exec 'find . -name "*.xcodeproj" 2>/dev/null').split /\/(?=[^\/]*$)/)[0] # cd to the project_directory Dir.chdir(project_directory) # set build number and project number in project file pwd puts Util::Shell.exec "xcrun agvtool new-version -all #{build_number}", false puts Util::Shell.exec "xcrun agvtool new-marketing-version SNAPSHOT" # cd back to the working_directory Dir.chdir(working_directory) elsif @platform == 'android' updater = VersionUpdate::Gradle.new(@repository_root) updater.update_qa_version(build_number) end # Create a new build commit, push to QA, checkout develop Util::Git.create_commit( "Update build number to #{build_number} for delivery to QA", story) puts Util::Shell.exec "git push" puts Util::Shell.exec "git checkout #{current_branch}" i_stories = included_stories @project, story deliver_stories i_stories, story end |