pt-flow 1.0.0 → 1.1.0

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: a26b6831610100b35a16f96da432f35aec1806f7
4
- data.tar.gz: 81a35f52d0247c3e5736a8bba8ce98ac850425ae
3
+ metadata.gz: 1383db0246599cfecba2fe73fc784b868f4e2639
4
+ data.tar.gz: e11d6c527961ee229e531ef86cafb1da34cdbd0f
5
5
  SHA512:
6
- metadata.gz: c4d69e7a53b87df1e0f15bc7e7d6fb780b8ffc78da6bdf6737bddb792edda6d81d20a2213620ecb8d0d435416560796db84b7b84547cd8ef65b6bf55f796a74f
7
- data.tar.gz: 8b3efd25f8840d8673ac5e00a67d3fbc04d4d57741c4edcb1a1f1d09f4788990d33ee40da58d15d0aeda35765d8b0e935918518c4e8f153effcb1a090c100164
6
+ metadata.gz: 1481f08cfcebd792ae88b5c72323a013e443beb0b53cb1ac6b347afe7b9532a0405bb769374b4443303acac8bdaa39955b7688d4c993108fccf12edd0f8c27b7
7
+ data.tar.gz: 2f3495368acf1f9b9fab00b720274e92f2274922e583e4bf1519aacb9f3d3a582e50443135080b55574469a448e97d5f40c70e9c7eb6262e9acc444c2463db9d
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
- script: "rake"
2
+ script: 'git config --global user.name "Your Name" && git config --global user.email "you@example.com" && rake'
3
3
  rvm:
4
- - 1.9.2
5
4
  - 1.9.3
5
+ - 2.0.0
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # pt-flow
1
+ # pt-flow [![Build Status](https://travis-ci.org/balvig/pt-flow.svg?branch=master)](https://travis-ci.org/balvig/pt-flow)
2
2
 
3
3
  Our workflow, gemified.
4
4
 
data/lib/pt-flow/ui.rb CHANGED
@@ -39,6 +39,7 @@ module PT::Flow
39
39
 
40
40
  run("hub pull-request -b #{branch.target} -h #{repo.user}:#{branch} -m \"#{title}\"")
41
41
  finish_task(task)
42
+ merge! if @params.include?('--merge')
42
43
  end
43
44
 
44
45
  def cleanup
@@ -79,6 +80,14 @@ module PT::Flow
79
80
  end
80
81
  end
81
82
 
83
+ def merge!
84
+ finished_branch = branch
85
+ run "git checkout #{finished_branch.target}"
86
+ run "git pull"
87
+ run "git merge #{finished_branch}"
88
+ run "git push origin #{finished_branch.target}"
89
+ end
90
+
82
91
  def run(command)
83
92
  title(command)
84
93
  error("Error running: #{command}") unless system(command)
@@ -1,5 +1,5 @@
1
1
  module PT
2
2
  module Flow
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
@@ -1,113 +1,130 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe PT::Flow::UI do
4
-
5
- let(:endpoint) { "http://www.pivotaltracker.com/services/v3" }
6
- let(:prompt) { double('HighLine') }
7
-
8
- before do
9
- HighLine.stub(new: prompt)
10
- stub_request(:get, /projects$/).to_return(body: fixture_file('projects.xml'))
11
- stub_request(:get, /stories\?/).to_return(body: fixture_file('stories.xml'))
12
- stub_request(:post, /stories$/).to_return(body: fixture_file('chore.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") }
3
+ module PT::Flow
4
+ describe UI do
5
+
6
+ let(:endpoint) { "http://www.pivotaltracker.com/services/v3" }
7
+ let(:prompt) { double('HighLine') }
8
+
9
+ before do
10
+ HighLine.stub(new: prompt)
11
+ stub_request(:get, /projects$/).to_return(body: fixture_file('projects.xml'))
12
+ stub_request(:get, /stories\?/).to_return(body: fixture_file('stories.xml'))
13
+ stub_request(:post, /stories$/).to_return(body: fixture_file('chore.xml'))
14
+ stub_request(:any, /stories\/\d+/).to_return do |request|
15
+ id = request.uri.to_s.split('/').last
16
+ { body: fixture_file("story_#{id}.xml") }
17
+ end
16
18
  end
17
- end
18
19
 
19
- describe '#start' do
20
- context 'given an unestimated story' do
21
- it "shows lists of stories - choosing one asks you to estimate, starts/assigns the story on pt and checks out a new branch." do
22
- prompt.should_receive(:ask).with("Please select a task to start working on (1-14, 'q' to exit)".bold).and_return('2')
23
- prompt.should_receive(:ask).with("How many points do you estimate for it? (0,1,2,3)".bold).and_return('3')
20
+ describe '#start' do
21
+ context 'given an unestimated story' do
22
+ it "shows lists of stories - choosing one asks you to estimate, starts/assigns the story on pt and checks out a new branch." do
23
+ prompt.should_receive(:ask).with("Please select a task to start working on (1-14, 'q' to exit)".bold).and_return('2')
24
+ prompt.should_receive(:ask).with("How many points do you estimate for it? (0,1,2,3)".bold).and_return('3')
24
25
 
25
- PT::Flow::UI.new('start')
26
+ UI.new('start')
26
27
 
27
- WebMock.should have_requested(:get, "#{endpoint}/projects/102622/stories?filter=current_state:unscheduled,unstarted,started")
28
- WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<estimate>3<\/estimate>/)
29
- WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<owned_by>Jon Mischo<\/owned_by>/)
30
- WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<current_state>started<\/current_state>/)
28
+ WebMock.should have_requested(:get, "#{endpoint}/projects/102622/stories?filter=current_state:unscheduled,unstarted,started")
29
+ WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<estimate>3<\/estimate>/)
30
+ WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<owned_by>Jon Mischo<\/owned_by>/)
31
+ WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<current_state>started<\/current_state>/)
31
32
 
32
- current_branch.should == 'master.as-a-user-i-should-see-an-unestimated-feature-with-.4459994'
33
+ current_branch.should == 'master.as-a-user-i-should-see-an-unestimated-feature-with-.4459994'
34
+ end
33
35
  end
34
- end
35
36
 
36
- context 'given an already estimated story' do
37
- it "does not prompt to estimate" do
38
- prompt.should_receive(:ask).once.with("Please select a task to start working on (1-14, 'q' to exit)".bold).and_return('3')
39
- PT::Flow::UI.new('start')
37
+ context 'given an already estimated story' do
38
+ it "does not prompt to estimate" do
39
+ prompt.should_receive(:ask).once.with("Please select a task to start working on (1-14, 'q' to exit)".bold).and_return('3')
40
+ UI.new('start')
41
+ end
40
42
  end
41
- end
42
43
 
43
- context 'when run from a feature branch' do
44
- before { system('git checkout -B new_feature') }
44
+ context 'when run from a feature branch' do
45
+ before { system('git checkout -B new_feature') }
45
46
 
46
- it "creates an appropriately namespaced branch" do
47
- prompt.should_receive(:ask).and_return('3')
48
- PT::Flow::UI.new('start')
49
- current_branch.should == 'new_feature.this-is-for-comments.4460038'
47
+ it "creates an appropriately namespaced branch" do
48
+ prompt.should_receive(:ask).and_return('3')
49
+ UI.new('start')
50
+ current_branch.should == 'new_feature.this-is-for-comments.4460038'
51
+ end
50
52
  end
51
- end
52
53
 
53
- context 'when run from an existing story branch' do
54
- before { system('git checkout -B new_feature.as-a-user-i-should.4459994') }
54
+ context 'when run from an existing story branch' do
55
+ before { system('git checkout -B new_feature.as-a-user-i-should.4459994') }
55
56
 
56
- it "creates a branch within the same namespace" do
57
- prompt.should_receive(:ask).and_return('3')
58
- PT::Flow::UI.new('start')
59
- current_branch.should == 'new_feature.this-is-for-comments.4460038'
57
+ it "creates a branch within the same namespace" do
58
+ prompt.should_receive(:ask).and_return('3')
59
+ UI.new('start')
60
+ current_branch.should == 'new_feature.this-is-for-comments.4460038'
61
+ end
60
62
  end
61
- end
62
63
 
63
- context 'given a string' do
64
- it "creates and starts a new story with that name" do
65
- prompt.should_receive(:ask).with("Type? (c)hore, (b)ug, (f)eature".bold).and_return('c')
64
+ context 'given a string' do
65
+ it "creates and starts a new story with that name" do
66
+ prompt.should_receive(:ask).with("Type? (c)hore, (b)ug, (f)eature".bold).and_return('c')
66
67
 
67
- PT::Flow::UI.new('start', ['a new feature'])
68
+ UI.new('start', ['a new feature'])
68
69
 
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>/)
70
- WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<owned_by>Jon Mischo<\/owned_by>/)
71
- WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<current_state>started<\/current_state>/)
70
+ 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>/)
71
+ WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<owned_by>Jon Mischo<\/owned_by>/)
72
+ WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<current_state>started<\/current_state>/)
73
+ end
72
74
  end
73
75
  end
74
- end
75
76
 
76
- describe '#finish' do
77
- context 'ssh repo' do
77
+ describe '#finish' do
78
+ context 'ssh repo' do
79
+ before do
80
+ system('git checkout -B new_feature')
81
+ system('git remote rm origin')
82
+ system('git remote add origin git@github.com:cookpad/pt-flow.git')
83
+
84
+ prompt.should_receive(:ask).and_return('3')
85
+ UI.new('start')
86
+ end
87
+
88
+ context 'no options' do
89
+ it "pushes the current branch to origin, flags the story as finished, and opens a github pull request" do
90
+ UI.any_instance.should_receive(:run).with('git push origin new_feature.this-is-for-comments.4460038 -u')
91
+ UI.any_instance.should_receive(:run).with("hub pull-request -b new_feature -h cookpad:new_feature.this-is-for-comments.4460038 -m \"This is for comments [Delivers #4460038]\"")
92
+ UI.new('finish')
93
+ current_branch.should == 'new_feature.this-is-for-comments.4460038'
94
+ WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4460038").with(body: /<current_state>finished<\/current_state>/)
95
+ end
96
+ end
97
+
98
+ context 'given option --merge' do
99
+ it "pushes the current branch to origin, flags the story as finished, opens github pull request, merges it in and returns to master and pulls" do
100
+ UI.any_instance.should_receive(:run).with('git push origin new_feature.this-is-for-comments.4460038 -u')
101
+ UI.any_instance.should_receive(:run).with("hub pull-request -b new_feature -h cookpad:new_feature.this-is-for-comments.4460038 -m \"This is for comments [Delivers #4460038]\"")
102
+ UI.any_instance.should_receive(:run).with('git checkout new_feature')
103
+ UI.any_instance.should_receive(:run).with('git pull')
104
+ UI.any_instance.should_receive(:run).with('git merge new_feature.this-is-for-comments.4460038')
105
+ UI.any_instance.should_receive(:run).with('git push origin new_feature')
106
+ UI.new('finish', ['--merge'])
107
+ end
108
+ end
109
+ end
110
+ end
111
+
112
+ context 'https repo' do
78
113
  before do
79
114
  system('git checkout -B new_feature')
80
115
  system('git remote rm origin')
81
- system('git remote add origin git@github.com:cookpad/pt-flow.git')
116
+ system('git remote add origin https://github.com/balvig/pt-flow.git')
82
117
 
83
118
  prompt.should_receive(:ask).and_return('3')
84
- PT::Flow::UI.new('start')
119
+ UI.new('start')
85
120
  end
86
121
 
87
122
  it "pushes the current branch to origin, flags the story as finished, and opens a github pull request" do
88
- PT::Flow::UI.any_instance.should_receive(:run).with('git push origin new_feature.this-is-for-comments.4460038 -u')
89
- PT::Flow::UI.any_instance.should_receive(:run).with("hub pull-request -b new_feature -h cookpad:new_feature.this-is-for-comments.4460038 -m \"This is for comments [Delivers #4460038]\"")
90
- PT::Flow::UI.new('finish')
91
- current_branch.should == 'new_feature.this-is-for-comments.4460038'
92
- WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4460038").with(body: /<current_state>finished<\/current_state>/)
123
+ UI.any_instance.should_receive(:run).with('git push origin new_feature.this-is-for-comments.4460038 -u')
124
+ UI.any_instance.should_receive(:run).with("hub pull-request -b new_feature -h balvig:new_feature.this-is-for-comments.4460038 -m \"This is for comments [Delivers #4460038]\"")
125
+ UI.new('finish')
93
126
  end
94
127
  end
95
- end
96
-
97
- context 'https repo' do
98
- before do
99
- system('git checkout -B new_feature')
100
- system('git remote rm origin')
101
- system('git remote add origin https://github.com/balvig/pt-flow.git')
102
-
103
- prompt.should_receive(:ask).and_return('3')
104
- PT::Flow::UI.new('start')
105
- end
106
128
 
107
- it "pushes the current branch to origin, flags the story as finished, and opens a github pull request" do
108
- PT::Flow::UI.any_instance.should_receive(:run).with('git push origin new_feature.this-is-for-comments.4460038 -u')
109
- PT::Flow::UI.any_instance.should_receive(:run).with("hub pull-request -b new_feature -h balvig:new_feature.this-is-for-comments.4460038 -m \"This is for comments [Delivers #4460038]\"")
110
- PT::Flow::UI.new('finish')
111
- end
112
129
  end
113
130
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pt-flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Balvig
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-06 00:00:00.000000000 Z
11
+ date: 2014-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pt
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  version: '0'
199
199
  requirements: []
200
200
  rubyforge_project:
201
- rubygems_version: 2.1.0
201
+ rubygems_version: 2.2.2
202
202
  signing_key:
203
203
  specification_version: 4
204
204
  summary: Some extra methods for the pt gem to use in our dev flow.