class GitPivotalTrackerIntegration::Command::Finish
The class that encapsulates finishing a Pivotal Tracker Story
Public Instance Methods
commit_new_build()
click to toggle source
# File lib/git-pivotal-tracker-integration/command/finish.rb, line 53 def commit_new_build # Update version and build numbers # For iOS project the build number separator should be "-" separator = '_' # default separator separator = '-' if OS.mac? && @platform.downcase == 'ios' build_number = Time.now.utc.strftime("%y%m%d#{separator}%H%M") working_directory = pwd puts "build_number:#{build_number}" puts "working_directory:#{working_directory}*" 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] return if project_directory.nil? # 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.downcase == 'android' updater = VersionUpdate::Gradle.new(@repository_root) updater.update_dev_version(build_number) end # Create a new build commit, push to develop Util::Git.create_commit( "Update build number to #{build_number}", @configuration.story(@project)) end
run(argument)
click to toggle source
Finishes a Pivotal Tracker story by doing the following steps:
-
Check that the pending merge will be trivial
-
Merge the development branch into the root branch
-
Delete the development branch
-
Push changes to remote
@return [void]
# File lib/git-pivotal-tracker-integration/command/finish.rb, line 29 def run(argument) $LOG.debug("#{self.class} in project:#{@project.name} pwd:#{pwd} branch:#{Util::Git.branch_name}") no_complete = argument =~ /--no-complete/ branch_status_check = Util::Shell.exec "git status -s" abort "\n\nThere are some unstaged changes in your current branch. Please do execute the below commands first and then try with git finish \n git add . \n git commit -m '<your-commit-message>'" unless branch_status_check.empty? # ask("pause") Util::Git.trivial_merge? story = @configuration.story(@project) $LOG.debug("configuration:#{@configuration}") $LOG.debug("project:#{@project}") $LOG.debug("story:#{story}") self.commit_new_build Util::Git.merge(@configuration.story(@project), no_complete) Util::Git.push Util::Git.branch_name story.add_label('need code review') end