pt-flow 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -15,14 +15,14 @@ Set up webhook for Pivotal Tracker:
15
15
  ### Usage
16
16
 
17
17
  ```bash
18
- $ flow start
18
+ $ git start
19
19
  # shows lists of tasks - choosing one starts/assigns the task on pt and checks out a new branch.
20
20
 
21
- $ flow finish
21
+ $ git finish
22
22
  # pushes branch, finishes task on pt, and creates a pull request
23
23
  # reviewer comments :+1: to approve on github
24
24
  # committer presses merge button on github which delivers task on pivotal tracker
25
25
 
26
- $ flow cleanup
26
+ $ git cleanup
27
27
  # cleans up local/remote story branches already merged with current release branch
28
28
  ```
data/bin/git-cleanup ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
5
+ require 'pt-flow'
6
+
7
+ PT::Flow::UI.new('cleanup', ARGV)
data/bin/git-create ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
5
+ require 'pt-flow'
6
+
7
+ PT::Flow::UI.new('create', ARGV)
data/bin/git-finish ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
5
+ require 'pt-flow'
6
+
7
+ PT::Flow::UI.new('finish', ARGV)
data/bin/git-start ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
5
+ require 'pt-flow'
6
+
7
+ PT::Flow::UI.new('start', ARGV)
data/lib/pt-flow/ui.rb CHANGED
@@ -1,9 +1,8 @@
1
1
  module PT::Flow
2
2
  class UI < PT::UI
3
3
 
4
- def my_work #default command
5
- super
6
- help
4
+ def initialize(command, args = [])
5
+ super [command] + (args)
7
6
  end
8
7
 
9
8
  def start
@@ -20,15 +19,6 @@ module PT::Flow
20
19
  run("git checkout -b #{Branch.from_task(task)}")
21
20
  end
22
21
 
23
- def finish
24
- run("git push origin #{branch} -u")
25
- task = PivotalTracker::Story.find(branch.task_id, @project.id)
26
- title = task.name.gsub('"',"'") + " [Delivers ##{task.id}]"
27
-
28
- run("hub pull-request -b #{branch.target} -h #{repo.user}:#{branch} \"#{title}\"")
29
- finish_task(task)
30
- end
31
-
32
22
  def create
33
23
  name = @params[0] || ask("Name for the new story:")
34
24
  types = { 'c' => 'chore', 'b' => 'bug', 'f' => 'feature' }
@@ -42,6 +32,15 @@ module PT::Flow
42
32
  end
43
33
  end
44
34
 
35
+ def finish
36
+ run("git push origin #{branch} -u")
37
+ task = PivotalTracker::Story.find(branch.task_id, @project.id)
38
+ title = task.name.gsub('"',"'") + " [Delivers ##{task.id}]"
39
+
40
+ run("hub pull-request -b #{branch.target} -h #{repo.user}:#{branch} \"#{title}\"")
41
+ finish_task(task)
42
+ end
43
+
45
44
  def cleanup
46
45
  title("Cleaning merged story branches for [#{branch.target}]")
47
46
 
@@ -61,17 +60,6 @@ module PT::Flow
61
60
  congrats("Deleted branches merged with [#{branch.target}]")
62
61
  end
63
62
 
64
- def help
65
- if ARGV[0] && ARGV[0] != 'help'
66
- message("Command #{ARGV[0]} not recognized. Showing help.")
67
- end
68
-
69
- title("Command line usage")
70
- puts("flow start # start working on a story")
71
- puts("flow finish # finish a story and create a pull request")
72
- puts("flow cleanup # deleted merged local/remote branches and prune origin")
73
- end
74
-
75
63
  private
76
64
 
77
65
  def branch
@@ -1,5 +1,5 @@
1
1
  module PT
2
2
  module Flow
3
- VERSION = "0.7.0"
3
+ VERSION = "0.8.0"
4
4
  end
5
5
  end
data/pt-flow.gemspec CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  gem.add_dependency 'pt'
19
19
  gem.add_dependency 'hub'
20
+ gem.add_dependency 'pivotal-tracker', '< 0.5.9'
20
21
  gem.add_dependency 'active_support'
21
22
  gem.add_dependency 'i18n'
22
23
  gem.add_dependency 'hirb-colors'
File without changes
@@ -0,0 +1,46 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <story>
3
+ <id type="integer">4460038</id>
4
+ <project_id type="integer">102622</project_id>
5
+ <story_type>feature</story_type>
6
+ <url>http://www.pivotaltracker.com/story/show/4460038</url>
7
+ <estimate type="integer">1</estimate>
8
+ <current_state>unstarted</current_state>
9
+ <description>This is a story that has comments.</description>
10
+ <name>This is for comments</name>
11
+ <requested_by>Jon Mischo</requested_by>
12
+ <created_at type="datetime">2010/07/27 21:53:16 UTC</created_at>
13
+ <updated_at type="datetime">2010/07/27 22:20:48 UTC</updated_at>
14
+ <notes type="array">
15
+ <note>
16
+ <id type="integer">2111593</id>
17
+ <text>This is a comment...whee!</text>
18
+ <author>Jon</author>
19
+ <noted_at type="datetime">2010/07/27 22:15:48 UTC</noted_at>
20
+ </note>
21
+ <note>
22
+ <id type="integer">2128955</id>
23
+ <text>Test note</text>
24
+ <author>Test Suite Access</author>
25
+ <noted_at type="datetime">2010/07/29 18:15:09 UTC</noted_at>
26
+ </note>
27
+ <note>
28
+ <id type="integer">2128959</id>
29
+ <text>Test note</text>
30
+ <author>Test Suite Access</author>
31
+ <noted_at type="datetime">2010/07/29 18:16:12 UTC</noted_at>
32
+ </note>
33
+ <note>
34
+ <id type="integer">2129077</id>
35
+ <text>Test note</text>
36
+ <author>Test Suite Access</author>
37
+ <noted_at type="datetime">2010/07/29 18:22:26 UTC</noted_at>
38
+ </note>
39
+ <note>
40
+ <id type="integer">2129374</id>
41
+ <text>Test note</text>
42
+ <author>Test Suite Access</author>
43
+ <noted_at type="datetime">2010/07/29 18:55:44 UTC</noted_at>
44
+ </note>
45
+ </notes>
46
+ </story>
@@ -10,7 +10,10 @@ describe PT::Flow::UI do
10
10
  stub_request(:get, /projects$/).to_return(body: fixture_file('projects.xml'))
11
11
  stub_request(:get, /stories\?/).to_return(body: fixture_file('stories.xml'))
12
12
  stub_request(:post, /stories$/).to_return(body: fixture_file('chore.xml'))
13
- stub_request(:any, /stories\/\d+/).to_return(body: fixture_file('story.xml'))
13
+ stub_request(:any, /stories\/\d+/).to_return do |request|
14
+ id = request.uri.to_s.split('/').last
15
+ { body: fixture_file("story_#{id}.xml") }
16
+ end
14
17
  end
15
18
 
16
19
  describe '#start' do
@@ -19,7 +22,7 @@ describe PT::Flow::UI do
19
22
  prompt.should_receive(:ask).with("Please select a task to start working on (1-14, 'q' to exit)".bold).and_return('2')
20
23
  prompt.should_receive(:ask).with("How many points do you estimate for it? (0,1,2,3)".bold).and_return('3')
21
24
 
22
- PT::Flow::UI.new %w{ start }
25
+ PT::Flow::UI.new('start')
23
26
 
24
27
  WebMock.should have_requested(:get, "#{endpoint}/projects/102622/stories?filter=current_state:unscheduled,unstarted,started")
25
28
  WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<estimate>3<\/estimate>/)
@@ -33,7 +36,7 @@ describe PT::Flow::UI do
33
36
  context 'given an already estimated story' do
34
37
  it "does not prompt to estimate" do
35
38
  prompt.should_receive(:ask).once.with("Please select a task to start working on (1-14, 'q' to exit)".bold).and_return('3')
36
- PT::Flow::UI.new %w{ start }
39
+ PT::Flow::UI.new('start')
37
40
  end
38
41
  end
39
42
 
@@ -42,7 +45,7 @@ describe PT::Flow::UI do
42
45
 
43
46
  it "creates an appropriately namespaced branch" do
44
47
  prompt.should_receive(:ask).and_return('3')
45
- PT::Flow::UI.new %w{ start }
48
+ PT::Flow::UI.new('start')
46
49
  current_branch.should == 'new_feature.this-is-for-comments.4460038'
47
50
  end
48
51
  end
@@ -52,7 +55,7 @@ describe PT::Flow::UI do
52
55
 
53
56
  it "creates a branch within the same namespace" do
54
57
  prompt.should_receive(:ask).and_return('3')
55
- PT::Flow::UI.new %w{ start }
58
+ PT::Flow::UI.new('start')
56
59
  current_branch.should == 'new_feature.this-is-for-comments.4460038'
57
60
  end
58
61
  end
@@ -61,7 +64,7 @@ describe PT::Flow::UI do
61
64
  it "creates and starts a new story with that name" do
62
65
  prompt.should_receive(:ask).with("Type? (c)hore, (b)ug, (f)eature".bold).and_return('c')
63
66
 
64
- PT::Flow::UI.new ['start','a new feature']
67
+ PT::Flow::UI.new('start', ['a new feature'])
65
68
 
66
69
  WebMock.should have_requested(:post, "#{endpoint}/projects/102622/stories").with(body: /<name>a new feature<\/name>/).with(body: /<story_type>chore<\/story_type>/).with(body: /<requested_by>Jon Mischo<\/requested_by>/)
67
70
  WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<owned_by>Jon Mischo<\/owned_by>/)
@@ -72,17 +75,20 @@ describe PT::Flow::UI do
72
75
 
73
76
  describe '#finish' do
74
77
  before do
75
- #TODO: Stubbed endpoint ALWAYS returns story 4459994, need a way to check it is actually getting the right id from the branch
76
- system('git checkout -B new_feature.as-a-user-i-should.4459994')
78
+ system('git checkout -B new_feature')
79
+ system('git remote rm origin')
77
80
  system('git remote add origin git@github.com:cookpad/pt-flow.git')
81
+
82
+ prompt.should_receive(:ask).and_return('3')
83
+ PT::Flow::UI.new('start')
78
84
  end
79
85
 
80
86
  it "pushes the current branch to origin, flags the story as finished, and opens a github pull request" do
81
- PT::Flow::UI.any_instance.should_receive(:run).with('git push origin new_feature.as-a-user-i-should.4459994 -u')
82
- PT::Flow::UI.any_instance.should_receive(:run).with("hub pull-request -b new_feature -h cookpad:new_feature.as-a-user-i-should.4459994 \"As a user I should see an Unestimated Feature with a fairly long name [Delivers #4459994]\"")
83
- PT::Flow::UI.new %w{ finish }
84
- current_branch.should == 'new_feature.as-a-user-i-should.4459994'
85
- WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<current_state>finished<\/current_state>/)
87
+ PT::Flow::UI.any_instance.should_receive(:run).with('git push origin new_feature.this-is-for-comments.4460038 -u')
88
+ PT::Flow::UI.any_instance.should_receive(:run).with("hub pull-request -b new_feature -h cookpad:new_feature.this-is-for-comments.4460038 \"This is for comments [Delivers #4460038]\"")
89
+ PT::Flow::UI.new('finish')
90
+ current_branch.should == 'new_feature.this-is-for-comments.4460038'
91
+ WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4460038").with(body: /<current_state>finished<\/current_state>/)
86
92
  end
87
93
  end
88
94
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pt-flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-26 00:00:00.000000000 Z
12
+ date: 2012-11-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pt
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: pivotal-tracker
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - <
52
+ - !ruby/object:Gem::Version
53
+ version: 0.5.9
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - <
60
+ - !ruby/object:Gem::Version
61
+ version: 0.5.9
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: active_support
48
64
  requirement: !ruby/object:Gem::Requirement
@@ -175,7 +191,10 @@ description: Some extra methods for the pt gem to use in our dev flow.
175
191
  email:
176
192
  - jens@balvig.com
177
193
  executables:
178
- - flow
194
+ - git-cleanup
195
+ - git-create
196
+ - git-finish
197
+ - git-start
179
198
  extensions: []
180
199
  extra_rdoc_files: []
181
200
  files:
@@ -186,7 +205,10 @@ files:
186
205
  - LICENSE
187
206
  - README.md
188
207
  - Rakefile
189
- - bin/flow
208
+ - bin/git-cleanup
209
+ - bin/git-create
210
+ - bin/git-finish
211
+ - bin/git-start
190
212
  - lib/pt-flow.rb
191
213
  - lib/pt-flow/branch.rb
192
214
  - lib/pt-flow/repo.rb
@@ -200,7 +222,8 @@ files:
200
222
  - spec/fixtures/local_config.yml
201
223
  - spec/fixtures/projects.xml
202
224
  - spec/fixtures/stories.xml
203
- - spec/fixtures/story.xml
225
+ - spec/fixtures/story_4459994.xml
226
+ - spec/fixtures/story_4460038.xml
204
227
  - spec/lib/pt-flow/ui_spec.rb
205
228
  - spec/spec_helper.rb
206
229
  - spec/support/dummy.rb
@@ -221,7 +244,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
221
244
  version: '0'
222
245
  segments:
223
246
  - 0
224
- hash: 1204691239520265833
247
+ hash: 2421475747873387563
225
248
  required_rubygems_version: !ruby/object:Gem::Requirement
226
249
  none: false
227
250
  requirements:
@@ -230,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
253
  version: '0'
231
254
  segments:
232
255
  - 0
233
- hash: 1204691239520265833
256
+ hash: 2421475747873387563
234
257
  requirements: []
235
258
  rubyforge_project:
236
259
  rubygems_version: 1.8.23
@@ -243,7 +266,8 @@ test_files:
243
266
  - spec/fixtures/local_config.yml
244
267
  - spec/fixtures/projects.xml
245
268
  - spec/fixtures/stories.xml
246
- - spec/fixtures/story.xml
269
+ - spec/fixtures/story_4459994.xml
270
+ - spec/fixtures/story_4460038.xml
247
271
  - spec/lib/pt-flow/ui_spec.rb
248
272
  - spec/spec_helper.rb
249
273
  - spec/support/dummy.rb
data/bin/flow DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'pathname'
4
-
5
- lib = (Pathname.new(__FILE__).realpath.dirname + '../lib').to_s
6
- $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
7
-
8
- require 'pt-flow'
9
-
10
- PT::Flow::UI.new ARGV