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 +4 -4
- data/.travis.yml +2 -2
- data/README.md +1 -1
- data/lib/pt-flow/ui.rb +9 -0
- data/lib/pt-flow/version.rb +1 -1
- data/spec/lib/pt-flow/ui_spec.rb +95 -78
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1383db0246599cfecba2fe73fc784b868f4e2639
|
4
|
+
data.tar.gz: e11d6c527961ee229e531ef86cafb1da34cdbd0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1481f08cfcebd792ae88b5c72323a013e443beb0b53cb1ac6b347afe7b9532a0405bb769374b4443303acac8bdaa39955b7688d4c993108fccf12edd0f8c27b7
|
7
|
+
data.tar.gz: 2f3495368acf1f9b9fab00b720274e92f2274922e583e4bf1519aacb9f3d3a582e50443135080b55574469a448e97d5f40c70e9c7eb6262e9acc444c2463db9d
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
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)
|
data/lib/pt-flow/version.rb
CHANGED
data/spec/lib/pt-flow/ui_spec.rb
CHANGED
@@ -1,113 +1,130 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
26
|
+
UI.new('start')
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
44
|
-
|
44
|
+
context 'when run from a feature branch' do
|
45
|
+
before { system('git checkout -B new_feature') }
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
-
|
54
|
-
|
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
-
|
64
|
-
|
65
|
-
|
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
|
-
|
68
|
+
UI.new('start', ['a new feature'])
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
|
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
|
-
|
77
|
-
|
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
|
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
|
-
|
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
|
-
|
89
|
-
|
90
|
-
|
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.
|
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-
|
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.
|
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.
|