Class: GitPivotalTrackerIntegration::Command::Release

Inherits:
Base
  • Object
show all
Defined in:
lib/git-pivotal-tracker-integration/command/release.rb

Overview

The class that encapsulates releasing a Pivotal Tracker Story

Constant Summary

Constants inherited from Base

Base::TIMER_TOKENS

Instance Method Summary collapse

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

#run(filter) ⇒ void

This method returns an undefined value.

Releases a Pivotal Tracker story by doing the following steps:

  • Update the version to the release version

  • Create a tag for the release version

  • Update the version to the new development version

  • Push tag and changes to remote

Parameters:

  • filter (String, nil)

    a filter for selecting the release to start. This filter can be either:

    • a story id

    • nil



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
99
100
101
102
103
# File 'lib/git-pivotal-tracker-integration/command/release.rb', line 36

def run(filter)
  $LOG.debug("#{self.class} in project:#{@project.name} pwd:#{pwd} branch:#{GitPivotalTrackerIntegration::Util::Git.branch_name}")
  story = GitPivotalTrackerIntegration::Util::Story.select_release(@project, filter.nil? ? 'v' : filter)
  place_version_release story
  pull_out_rejected_stories story
  GitPivotalTrackerIntegration::Util::Story.pretty_print story
  $LOG.debug("story:#{story.name}")

  current_branch = GitPivotalTrackerIntegration::Util::Git.branch_name

  # checkout QA branch
  # Update QA from origin
  puts GitPivotalTrackerIntegration::Util::Shell.exec "git checkout QA"
  puts GitPivotalTrackerIntegration::Util::Shell.exec "git fetch"
  GitPivotalTrackerIntegration::Util::Shell.exec "git merge -s recursive --strategy-option theirs origin QA"

  # checkout master branch
  # Merge QA into master
  puts GitPivotalTrackerIntegration::Util::Shell.exec "git checkout master"
  puts GitPivotalTrackerIntegration::Util::Shell.exec "git pull"
  if (GitPivotalTrackerIntegration::Util::Shell.exec "git merge -s recursive --strategy-option theirs QA")
    puts "Merged 'QA' in to 'master'"
  else
    abort "FAILED to merge 'QA' in to 'master'"
  end

  # Update version and build numbers
  version_number    = story.name.dup
  version_number[0] = ""
  working_directory = pwd

  puts "storyNAME:#{story.name}"
  puts "version_number:#{version_number}"
  puts "working_directory:#{working_directory}*"

  if (OS.mac? && ["y","ios"].include?(@platform.downcase))
    project_directory = ((GitPivotalTrackerIntegration::Util::Shell.exec 'find . -name "*.xcodeproj" 2>/dev/null').split /\/(?=[^\/]*$)/)[0]

    # cd to the project_directory
    Dir.chdir(project_directory)

    # set project number in project file
    pwd
    puts GitPivotalTrackerIntegration::Util::Shell.exec "xcrun agvtool new-marketing-version #{version_number}"

    # cd back to the working_directory
    Dir.chdir(working_directory)
  end

  # Create a new build commit, push to QA, checkout develop
  puts GitPivotalTrackerIntegration::Util::Git.create_commit( "Update version number to #{version_number} for delivery to QA", story)
  puts GitPivotalTrackerIntegration::Util::Shell.exec "git push"
  puts GitPivotalTrackerIntegration::Util::Shell.exec "git checkout #{current_branch}"

  s_labels_string = story.labels
  s_labels = ""
  if (s_labels_string)
    s_labels = s_labels_string.split(",")
    s_labels << story.name
    s_labels_string = s_labels.uniq.join(",")
  else
    s_labels_string = story.name
  end

  puts "labels:#{s_labels_string}"
  story.update(:labels => s_labels_string)

end