v2gpti 0.2.0.3 → 0.2.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e69e16edb5358423c49a4b109ee611c055fe3fd
4
- data.tar.gz: 2c90f667d52bf131e02184ce36c4424f546cc64b
3
+ metadata.gz: eb7fe1c58e20da7e1d498fca6800378197b4314a
4
+ data.tar.gz: b5746858ddfffd3fca9fb1c442ae54c8e32432ac
5
5
  SHA512:
6
- metadata.gz: 80dfe2e1b23885f87719776b8aee175ec7cdd7eaa13d1bc19017053b6ece83128fbfc0207cdace35d82f0b47d9d2277dae44a43122b298fdeb642e07613ec596
7
- data.tar.gz: d2e46538da9bbdf4357e31fa0abd741484ef83b493ac89350583536a9865f40c5d0142015fd41655a08182d532986ad52c9dd1cdf3b073b743f3005e70886500
6
+ metadata.gz: 30613ae7a32c8d67e49f8e26f484d273594c63a5e65bbdaf35f1fe46d800bfe6fe2ce7b92e126e0fa561f411ab6e5f2d00132f2c6730b5ed65edc9fda736c5a8
7
+ data.tar.gz: 88c18c003d1aca06435a64d90291345f1b300ed41bba0de774fae8ded0f0e80030243fce1c00d011c885a2af026fa97a05517fcf53562b8311ed784c0876588d
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby -U
2
+ # v2gpti
3
+ # Copyright (c) 2014 V2 Solutions Inc.
4
+ # All Rights Reserved
5
+
6
+
7
+ require 'git-pivotal-tracker-integration/command/deliver'
8
+
9
+ GitPivotalTrackerIntegration::Command::Deliver.new().run ARGV[0]
@@ -0,0 +1,197 @@
1
+ # Git Pivotal Tracker Integration
2
+ # Copyright (c) 2013 the original author or authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require 'git-pivotal-tracker-integration/command/base'
17
+ require 'git-pivotal-tracker-integration/command/command'
18
+ require 'git-pivotal-tracker-integration/util/git'
19
+ require 'git-pivotal-tracker-integration/util/story'
20
+ require 'pivotal-tracker'
21
+
22
+ # The class that encapsulates starting a Pivotal Tracker Story
23
+ class GitPivotalTrackerIntegration::Command::Deliver < GitPivotalTrackerIntegration::Command::Base
24
+
25
+ # Starts a Pivotal Tracker story by doing the following steps:
26
+ # * Create a branch
27
+ # * Add default commit hook
28
+ # * Start the story on Pivotal Tracker
29
+ #
30
+ # @param [String, nil] filter a filter for selecting the story to start. This
31
+ # filter can be either:
32
+ # * a story id
33
+ # * a story type (feature, bug, chore)
34
+ # * +nil+
35
+ # @return [void]
36
+ def run(filter)
37
+ self.check_branch
38
+ story = GitPivotalTrackerIntegration::Util::Story.select_release @project
39
+
40
+ GitPivotalTrackerIntegration::Util::Story.pretty_print story
41
+
42
+ current_branch = GitPivotalTrackerIntegration::Util::Git.branch_name
43
+
44
+ GitPivotalTrackerIntegration::Util::Shell.exec "git checkout QA"
45
+ if (GitPivotalTrackerIntegration::Util::Shell.exec "git merge -s recursive --strategy-option theirs develop")
46
+ puts "Merged 'develop' in to 'QA'"
47
+ else
48
+ abort "FAILED to merge 'develop' in to 'QA'"
49
+ end
50
+
51
+ puts "storyNAME:#{story.name}"
52
+
53
+ build_number = story.name.dup
54
+ build_number[0] = ""
55
+ puts "storyNAME:#{story.name}"
56
+ puts "build_number:#{build_number}"
57
+ project_directory = ((GitPivotalTrackerIntegration::Util::Shell.exec 'find . -name "*.xcodeproj" 2>/dev/null').split /\/(?=[^\/]*$)/)[0]
58
+ working_directory = (GitPivotalTrackerIntegration::Util::Shell.exec "pwd").chop
59
+ puts "working_directory:#{working_directory}*"
60
+
61
+ # cd to the project_directory
62
+ Dir.chdir(project_directory)
63
+
64
+ # set build number and project number in project file
65
+ GitPivotalTrackerIntegration::Util::Shell.exec "pwd"
66
+ puts GitPivotalTrackerIntegration::Util::Shell.exec "xcrun agvtool new-version -all #{build_number}", false
67
+ puts GitPivotalTrackerIntegration::Util::Shell.exec "xcrun agvtool new-marketing-version SNAPSHOT"
68
+
69
+ # cd back to the working_directory
70
+ Dir.chdir(working_directory)
71
+
72
+ # Create a new build commit, push to QA, checkout develop
73
+ GitPivotalTrackerIntegration::Util::Git.create_commit( "Update build number to #{build_number} for delivery to QA", story)
74
+ puts GitPivotalTrackerIntegration::Util::Shell.exec "git push"
75
+ puts GitPivotalTrackerIntegration::Util::Shell.exec "git checkout develop"
76
+
77
+ i_stories = included_stories @project, story
78
+ deliver_stories i_stories, story
79
+
80
+ end
81
+
82
+ def check_branch
83
+
84
+ current_branch = GitPivotalTrackerIntegration::Util::Git.branch_name
85
+
86
+ suggested_branch = "develop"
87
+
88
+ if !suggested_branch.nil? && suggested_branch.length !=0 && current_branch != suggested_branch
89
+ should_chage_branch = ask("Your currently checked out branch is '#{current_branch}'. Do you want to checkout '#{suggested_branch}' before starting?(Y/n)")
90
+ if should_chage_branch != "n"
91
+ print "Checking out branch '#{suggested_branch}'...\n\n"
92
+ GitPivotalTrackerIntegration::Util::Shell.exec "git checkout #{suggested_branch}"
93
+ GitPivotalTrackerIntegration::Util::Shell.exec 'git pull'
94
+
95
+ else
96
+ abort "You must be on the #{suggested_branch} branch to run this command."
97
+ end
98
+
99
+ end
100
+
101
+ end
102
+
103
+ private
104
+
105
+ CANDIDATE_STATES = %w(finished unstarted).freeze
106
+ CANDIDATE_TYPES = %w(bug chore feature release)
107
+
108
+ def deliver_stories(stories, build_story)
109
+ all_stories = stories.dup
110
+ all_stories << build_story
111
+ all_stories.each {|story|
112
+ puts "story class:#{story.class}"
113
+ s_labels_string = story.labels
114
+ s_labels = ""
115
+ if (s_labels_string)
116
+ s_labels = s_labels_string.split(",")
117
+ s_labels << build_story.name
118
+ s_labels_string = s_labels.uniq.join(",")
119
+ else
120
+ s_labels_string = build_story.name
121
+ end
122
+
123
+ puts "labels:#{s_labels_string}"
124
+ story.update(:labels => s_labels_string)
125
+ if (story.story_type == "feature") || (story.story_type == "bug")
126
+ story.update(:current_state => "delivered")
127
+ elsif (story.story_type == "chore")
128
+ story.update(:current_state => "accepted")
129
+ end
130
+ }
131
+ end
132
+
133
+ def included_stories(project, build_story)
134
+
135
+ criteria = {
136
+ :current_state => CANDIDATE_STATES,
137
+ :limit => 1000,
138
+ :story_type => CANDIDATE_TYPES
139
+ }
140
+
141
+
142
+ candidates = project.stories.all criteria
143
+
144
+ # only include stories that have been estimated
145
+ estimated_candidates = Array.new
146
+ val_is_valid = true
147
+ puts "Included stories:\n"
148
+ candidates.each {|val|
149
+ val_is_valid = true
150
+ if (val.id == build_story.id)
151
+ break
152
+ end
153
+ if (val.current_state != "finished")
154
+ val_is_valid = false
155
+ end
156
+ if (val.story_type == "release")
157
+ val_is_valid = false
158
+ end
159
+ if val_is_valid
160
+ # puts "val_is_valid:#{val_is_valid}"
161
+ estimated_candidates << val
162
+ puts "#{val.id}"
163
+
164
+ end
165
+ }
166
+ candidates = estimated_candidates
167
+ end
168
+
169
+
170
+
171
+ def development_branch_name(story)
172
+ prefix = "#{story.id}-"
173
+ story_name = "#{story.name.gsub(/[^0-9a-z\\s]/i, '_')}"
174
+ if(story_name.length > 30)
175
+ suggested_suffix = story_name[0..27]
176
+ suggested_suffix << "__"
177
+ else
178
+ suggested_suffix = story_name
179
+ end
180
+ branch_name = "#{prefix}" + ask("Enter branch name (#{story.id}-<#{suggested_suffix}>): ")
181
+ puts
182
+ if branch_name == "#{prefix}"
183
+ branch_name << suggested_suffix
184
+ end
185
+ branch_name.gsub(/[^0-9a-z\\s\-]/i, '_')
186
+ end
187
+
188
+ def start_on_tracker(story)
189
+ print 'Starting story on Pivotal Tracker... '
190
+ story.update(
191
+ :current_state => 'started',
192
+ :owned_by => GitPivotalTrackerIntegration::Util::Git.get_config('user.name')
193
+ )
194
+ puts 'OK'
195
+ end
196
+
197
+ end
@@ -53,7 +53,7 @@ class GitPivotalTrackerIntegration::Util::Story
53
53
  # * +nil+: offers the user a selection of stories of all types
54
54
  # @param [Fixnum] limit The number maximum number of stories the user can choose from
55
55
  # @return [PivotalTracker::Story] The Pivotal Tracker story selected by the user
56
- def self.select_story(project, filter = nil, limit = 5)
56
+ def self.select_story(project, filter = nil, limit = 12)
57
57
  if filter =~ /[[:digit:]]/
58
58
  story = project.stories.find filter.to_i
59
59
  else
@@ -63,6 +63,21 @@ class GitPivotalTrackerIntegration::Util::Story
63
63
  story
64
64
  end
65
65
 
66
+ def self.select_release(project, filter = 'b', limit = 10)
67
+ if filter =~ /[[:digit:]]/
68
+ story = project.stories.find filter.to_i
69
+ if story.(story_type != "release")
70
+ story = nil
71
+ puts "Specified story##{filter} is not a valid release story"
72
+ abort 'FAIL'
73
+ end
74
+ else
75
+ story = find_story project, filter, limit
76
+ end
77
+
78
+ story
79
+ end
80
+
66
81
  private
67
82
 
68
83
  CANDIDATE_STATES = %w(rejected unstarted unscheduled).freeze
@@ -94,6 +109,10 @@ class GitPivotalTrackerIntegration::Util::Story
94
109
  end
95
110
 
96
111
  def self.find_story(project, type, limit)
112
+ if (type == "b" || type == "v")
113
+ release_type = type
114
+ type = "release"
115
+ end
97
116
  criteria = {
98
117
  :current_state => CANDIDATE_STATES,
99
118
  :limit => limit
@@ -106,11 +125,25 @@ class GitPivotalTrackerIntegration::Util::Story
106
125
 
107
126
  # only include stories that have been estimated
108
127
  estimated_candidates = Array.new
128
+ val_is_valid = true
109
129
  candidates.each {|val|
110
- #puts "story_type:#{val.story_type} estimate:#{val.estimate}"
111
- if !(val.story_type == "feature" && val.estimate < 0)
112
- estimated_candidates << val
130
+ val_is_valid = true
131
+ if (val.story_type == "feature" )
132
+ # puts "#{val.story_type} #{val.name}.estimate:#{val.estimate} "
133
+ if (val.estimate < 0)
134
+ # puts "#{val.estimate} < 0"
135
+ val_is_valid = false
136
+ end
137
+ elsif (val.story_type == "release")
138
+ if (val.name[0] != release_type)
139
+ val_is_valid = false
140
+ end
113
141
  end
142
+
143
+ if val_is_valid
144
+ # puts "val_is_valid:#{val_is_valid}"
145
+ estimated_candidates << val
146
+ end
114
147
  }
115
148
  candidates = estimated_candidates
116
149
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: v2gpti
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.3
4
+ version: 0.2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Hale
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-02 00:00:00.000000000 Z
12
+ date: 2014-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: highline
@@ -141,6 +141,7 @@ description: Provides a set of additional Git commands to help developers when w
141
141
  with Pivotal Tracker
142
142
  email: jeff@xxxxxxxxx.com
143
143
  executables:
144
+ - git-deliver
144
145
  - git-finish
145
146
  - git-release
146
147
  - git-start
@@ -150,12 +151,14 @@ files:
150
151
  - LICENSE
151
152
  - NOTICE
152
153
  - README.md
154
+ - bin/git-deliver
153
155
  - bin/git-finish
154
156
  - bin/git-release
155
157
  - bin/git-start
156
158
  - lib/git-pivotal-tracker-integration/command/base.rb
157
159
  - lib/git-pivotal-tracker-integration/command/command.rb
158
160
  - lib/git-pivotal-tracker-integration/command/configuration.rb
161
+ - lib/git-pivotal-tracker-integration/command/deliver.rb
159
162
  - lib/git-pivotal-tracker-integration/command/finish.rb
160
163
  - lib/git-pivotal-tracker-integration/command/prepare-commit-msg.sh
161
164
  - lib/git-pivotal-tracker-integration/command/release.rb