spire-git-pivotal-tracker 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +202 -0
- data/NOTICE +2 -0
- data/README.md +176 -0
- data/bin/git-finish +19 -0
- data/bin/git-release +19 -0
- data/bin/git-start +19 -0
- data/lib/git-pivotal-tracker-integration/command/base.rb +47 -0
- data/lib/git-pivotal-tracker-integration/command/command.rb +20 -0
- data/lib/git-pivotal-tracker-integration/command/configuration.rb +109 -0
- data/lib/git-pivotal-tracker-integration/command/finish.rb +57 -0
- data/lib/git-pivotal-tracker-integration/command/prepare-commit-msg.sh +26 -0
- data/lib/git-pivotal-tracker-integration/command/release.rb +56 -0
- data/lib/git-pivotal-tracker-integration/command/start.rb +67 -0
- data/lib/git-pivotal-tracker-integration/util/git.rb +263 -0
- data/lib/git-pivotal-tracker-integration/util/shell.rb +36 -0
- data/lib/git-pivotal-tracker-integration/util/story.rb +124 -0
- data/lib/git-pivotal-tracker-integration/util/util.rb +20 -0
- data/lib/git-pivotal-tracker-integration/version-update/gradle.rb +64 -0
- data/lib/git-pivotal-tracker-integration/version-update/version_update.rb +20 -0
- data/lib/git_pivotal_tracker_integration.rb +18 -0
- data/spec/git-pivotal-tracker-integration/command/base_spec.rb +38 -0
- data/spec/git-pivotal-tracker-integration/command/configuration_spec.rb +91 -0
- data/spec/git-pivotal-tracker-integration/command/finish_spec.rb +45 -0
- data/spec/git-pivotal-tracker-integration/command/release_spec.rb +57 -0
- data/spec/git-pivotal-tracker-integration/command/start_spec.rb +54 -0
- data/spec/git-pivotal-tracker-integration/util/git_spec.rb +235 -0
- data/spec/git-pivotal-tracker-integration/util/shell_spec.rb +52 -0
- data/spec/git-pivotal-tracker-integration/util/story_spec.rb +137 -0
- data/spec/git-pivotal-tracker-integration/version-update/gradle_spec.rb +74 -0
- metadata +215 -0
@@ -0,0 +1,57 @@
|
|
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 'spec_helper'
|
17
|
+
require 'git-pivotal-tracker-integration/command/configuration'
|
18
|
+
require 'git-pivotal-tracker-integration/command/release'
|
19
|
+
require 'git-pivotal-tracker-integration/util/git'
|
20
|
+
require 'git-pivotal-tracker-integration/util/story'
|
21
|
+
require 'pivotal-tracker'
|
22
|
+
|
23
|
+
describe GitPivotalTrackerIntegration::Command::Release do
|
24
|
+
|
25
|
+
before do
|
26
|
+
$stdout = StringIO.new
|
27
|
+
$stderr = StringIO.new
|
28
|
+
|
29
|
+
@project = double('project')
|
30
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:repository_root)
|
31
|
+
GitPivotalTrackerIntegration::Command::Configuration.any_instance.should_receive(:api_token)
|
32
|
+
GitPivotalTrackerIntegration::Command::Configuration.any_instance.should_receive(:project_id)
|
33
|
+
PivotalTracker::Project.should_receive(:find).and_return(@project)
|
34
|
+
@release = GitPivotalTrackerIntegration::Command::Release.new
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should run' do
|
38
|
+
story = PivotalTracker::Story.new(:id => 12345678)
|
39
|
+
updater = double('updater')
|
40
|
+
GitPivotalTrackerIntegration::Util::Story.should_receive(:select_story).and_return(story)
|
41
|
+
GitPivotalTrackerIntegration::Util::Story.should_receive(:pretty_print)
|
42
|
+
GitPivotalTrackerIntegration::VersionUpdate::Gradle.should_receive(:new).and_return(updater)
|
43
|
+
updater.should_receive(:supports?).and_return(true)
|
44
|
+
updater.should_receive(:current_version).and_return('test_current_version')
|
45
|
+
@release.should_receive(:ask).and_return('test_release_version')
|
46
|
+
@release.should_receive(:ask).and_return('test_next_version')
|
47
|
+
updater.should_receive(:update_version).with('test_release_version')
|
48
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:create_release_tag).with('test_release_version', story)
|
49
|
+
updater.should_receive(:update_version).with('test_next_version')
|
50
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:create_commit).with('test_next_version Development', story)
|
51
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return('master')
|
52
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:push).with('master', 'vtest_release_version')
|
53
|
+
|
54
|
+
@release.run(nil)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,54 @@
|
|
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 'spec_helper'
|
17
|
+
require 'git-pivotal-tracker-integration/command/configuration'
|
18
|
+
require 'git-pivotal-tracker-integration/command/start'
|
19
|
+
require 'git-pivotal-tracker-integration/util/git'
|
20
|
+
require 'git-pivotal-tracker-integration/util/story'
|
21
|
+
require 'pivotal-tracker'
|
22
|
+
|
23
|
+
describe GitPivotalTrackerIntegration::Command::Start do
|
24
|
+
|
25
|
+
before do
|
26
|
+
$stdout = StringIO.new
|
27
|
+
$stderr = StringIO.new
|
28
|
+
|
29
|
+
@project = double('project')
|
30
|
+
@story = double('story')
|
31
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:repository_root)
|
32
|
+
GitPivotalTrackerIntegration::Command::Configuration.any_instance.should_receive(:api_token)
|
33
|
+
GitPivotalTrackerIntegration::Command::Configuration.any_instance.should_receive(:project_id)
|
34
|
+
PivotalTracker::Project.should_receive(:find).and_return(@project)
|
35
|
+
@start = GitPivotalTrackerIntegration::Command::Start.new
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should run' do
|
39
|
+
GitPivotalTrackerIntegration::Util::Story.should_receive(:select_story).with(@project, 'test_filter').and_return(@story)
|
40
|
+
GitPivotalTrackerIntegration::Util::Story.should_receive(:pretty_print)
|
41
|
+
@story.should_receive(:id).twice.and_return(12345678)
|
42
|
+
@start.should_receive(:ask).and_return('development_branch')
|
43
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:create_branch).with('12345678-development_branch')
|
44
|
+
GitPivotalTrackerIntegration::Command::Configuration.any_instance.should_receive(:story=)
|
45
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:add_hook)
|
46
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with('user.name').and_return('test_owner')
|
47
|
+
@story.should_receive(:update).with(
|
48
|
+
:current_state => 'started',
|
49
|
+
:owned_by => 'test_owner'
|
50
|
+
)
|
51
|
+
|
52
|
+
@start.run 'test_filter'
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,235 @@
|
|
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 'spec_helper'
|
17
|
+
require 'git-pivotal-tracker-integration/util/git'
|
18
|
+
require 'git-pivotal-tracker-integration/util/shell'
|
19
|
+
|
20
|
+
describe GitPivotalTrackerIntegration::Util::Git do
|
21
|
+
|
22
|
+
before do
|
23
|
+
$stdout = StringIO.new
|
24
|
+
$stderr = StringIO.new
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should return the current branch name' do
|
28
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git branch').and_return(" master\n * dev_branch")
|
29
|
+
|
30
|
+
current_branch = GitPivotalTrackerIntegration::Util::Git.branch_name
|
31
|
+
|
32
|
+
expect(current_branch).to eq('dev_branch')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should return the repository root' do
|
36
|
+
Dir.mktmpdir do |root|
|
37
|
+
child_directory = File.expand_path 'child', root
|
38
|
+
Dir.mkdir child_directory
|
39
|
+
|
40
|
+
git_directory = File.expand_path '.git', root
|
41
|
+
Dir.mkdir git_directory
|
42
|
+
|
43
|
+
Dir.should_receive(:pwd).and_return(child_directory)
|
44
|
+
|
45
|
+
repository_root = GitPivotalTrackerIntegration::Util::Git.repository_root
|
46
|
+
|
47
|
+
expect(repository_root).to eq(root)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should raise an error there is no repository root' do
|
52
|
+
Dir.mktmpdir do |root|
|
53
|
+
child_directory = File.expand_path 'child', root
|
54
|
+
Dir.mkdir child_directory
|
55
|
+
|
56
|
+
Dir.should_receive(:pwd).and_return(child_directory)
|
57
|
+
|
58
|
+
expect { GitPivotalTrackerIntegration::Util::Git.repository_root }.to raise_error
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should get configuration when :branch scope is specified' do
|
63
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return('test_branch_name')
|
64
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git config branch.test_branch_name.test_key', false).and_return('test_value')
|
65
|
+
|
66
|
+
value = GitPivotalTrackerIntegration::Util::Git.get_config 'test_key', :branch
|
67
|
+
|
68
|
+
expect(value).to eq('test_value')
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should get configuration when :inherited scope is specified' do
|
72
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git config test_key', false).and_return('test_value')
|
73
|
+
|
74
|
+
value = GitPivotalTrackerIntegration::Util::Git.get_config 'test_key', :inherited
|
75
|
+
|
76
|
+
expect(value).to eq('test_value')
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should raise an error when an unknown scope is specified (get)' do
|
80
|
+
expect { GitPivotalTrackerIntegration::Util::Git.get_config 'test_key', :unknown }.to raise_error
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should set configuration when :branch scope is specified' do
|
84
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return('test_branch_name')
|
85
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git config --local branch.test_branch_name.test_key test_value')
|
86
|
+
|
87
|
+
GitPivotalTrackerIntegration::Util::Git.set_config 'test_key', 'test_value', :branch
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should set configuration when :global scope is specified' do
|
91
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git config --global test_key test_value')
|
92
|
+
|
93
|
+
GitPivotalTrackerIntegration::Util::Git.set_config 'test_key', 'test_value', :global
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should set configuration when :local scope is specified' do
|
97
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git config --local test_key test_value')
|
98
|
+
|
99
|
+
GitPivotalTrackerIntegration::Util::Git.set_config 'test_key', 'test_value', :local
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should raise an error when an unknown scope is specified (set)' do
|
103
|
+
expect { GitPivotalTrackerIntegration::Util::Git.set_config 'test_key', 'test_value', :unknown }.to raise_error
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should create a branch and set the root_branch and root_remote properties on it' do
|
107
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return('master')
|
108
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with('remote', :branch).and_return('origin')
|
109
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git pull --quiet --ff-only')
|
110
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).and_return('git checkout --quiet -b dev_branch')
|
111
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:set_config).with('root-branch', 'master', :branch)
|
112
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:set_config).with('root-remote', 'origin', :branch)
|
113
|
+
|
114
|
+
GitPivotalTrackerIntegration::Util::Git.create_branch 'dev_branch'
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should not add a hook if it already exists' do
|
118
|
+
Dir.mktmpdir do |root|
|
119
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:repository_root).and_return(root)
|
120
|
+
hook = "#{root}/.git/hooks/prepare-commit-msg"
|
121
|
+
File.should_receive(:exist?).with(hook).and_return(true)
|
122
|
+
|
123
|
+
GitPivotalTrackerIntegration::Util::Git.add_hook 'prepare-commit-msg', __FILE__
|
124
|
+
|
125
|
+
File.should_receive(:exist?).and_call_original
|
126
|
+
expect(File.exist?(hook)).to be_false
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'should add a hook if it does not exist' do
|
131
|
+
Dir.mktmpdir do |root|
|
132
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:repository_root).and_return(root)
|
133
|
+
hook = "#{root}/.git/hooks/prepare-commit-msg"
|
134
|
+
File.should_receive(:exist?).with(hook).and_return(false)
|
135
|
+
|
136
|
+
GitPivotalTrackerIntegration::Util::Git.add_hook 'prepare-commit-msg', __FILE__
|
137
|
+
|
138
|
+
File.should_receive(:exist?).and_call_original
|
139
|
+
expect(File.exist?(hook)).to be_true
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'should add a hook if it already exists and overwrite is true' do
|
144
|
+
Dir.mktmpdir do |root|
|
145
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:repository_root).and_return(root)
|
146
|
+
hook = "#{root}/.git/hooks/prepare-commit-msg"
|
147
|
+
|
148
|
+
GitPivotalTrackerIntegration::Util::Git.add_hook 'prepare-commit-msg', __FILE__, true
|
149
|
+
|
150
|
+
File.should_receive(:exist?).and_call_original
|
151
|
+
expect(File.exist?(hook)).to be_true
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'should fail if root tip and common_ancestor do not match' do
|
156
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return('development_branch')
|
157
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with('root-branch', :branch).and_return('master')
|
158
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git checkout --quiet master')
|
159
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git pull --quiet --ff-only')
|
160
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git checkout --quiet development_branch')
|
161
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git rev-parse master').and_return('root_tip')
|
162
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git merge-base master development_branch').and_return('common_ancestor')
|
163
|
+
|
164
|
+
lambda { GitPivotalTrackerIntegration::Util::Git.trivial_merge? }.should raise_error(SystemExit)
|
165
|
+
|
166
|
+
expect($stderr.string).to match(/FAIL/)
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'should pass if root tip and common ancestor match' do
|
170
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return('development_branch')
|
171
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with('root-branch', :branch).and_return('master')
|
172
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git checkout --quiet master')
|
173
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git pull --quiet --ff-only')
|
174
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git checkout --quiet development_branch')
|
175
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git rev-parse master').and_return('HEAD')
|
176
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git merge-base master development_branch').and_return('HEAD')
|
177
|
+
|
178
|
+
GitPivotalTrackerIntegration::Util::Git.trivial_merge?
|
179
|
+
|
180
|
+
expect($stdout.string).to match(/OK/)
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'should merge and delete branches' do
|
184
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return('development_branch')
|
185
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with('root-branch', :branch).and_return('master')
|
186
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git checkout --quiet master')
|
187
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with("git merge --quiet --no-ff -m \"Merge development_branch to master\n\n[Completes #12345678]\" development_branch")
|
188
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git branch --quiet -D development_branch')
|
189
|
+
|
190
|
+
GitPivotalTrackerIntegration::Util::Git.merge PivotalTracker::Story.new(:id => 12345678), nil
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'should suppress Completes statement' do
|
194
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return('development_branch')
|
195
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with('root-branch', :branch).and_return('master')
|
196
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git checkout --quiet master')
|
197
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with("git merge --quiet --no-ff -m \"Merge development_branch to master\n\n[#12345678]\" development_branch")
|
198
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git branch --quiet -D development_branch')
|
199
|
+
|
200
|
+
GitPivotalTrackerIntegration::Util::Git.merge PivotalTracker::Story.new(:id => 12345678), true
|
201
|
+
end
|
202
|
+
|
203
|
+
it 'should push changes without refs' do
|
204
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with('remote', :branch).and_return('origin')
|
205
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git push --quiet origin ')
|
206
|
+
|
207
|
+
GitPivotalTrackerIntegration::Util::Git.push
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'should push changes with refs' do
|
211
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:get_config).with('remote', :branch).and_return('origin')
|
212
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git push --quiet origin foo bar')
|
213
|
+
|
214
|
+
GitPivotalTrackerIntegration::Util::Git.push 'foo', 'bar'
|
215
|
+
end
|
216
|
+
|
217
|
+
it 'should create a commit' do
|
218
|
+
story = PivotalTracker::Story.new(:id => 123456789)
|
219
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with("git commit --quiet --all --allow-empty --message \"test_message\n\n[#123456789]\"")
|
220
|
+
|
221
|
+
GitPivotalTrackerIntegration::Util::Git.create_commit 'test_message', story
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'should create a release tag' do
|
225
|
+
story = PivotalTracker::Story.new(:id => 123456789)
|
226
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:branch_name).and_return('master')
|
227
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:create_branch).with('pivotal-tracker-release', false)
|
228
|
+
GitPivotalTrackerIntegration::Util::Git.should_receive(:create_commit).with('1.0.0.RELEASE Release', story)
|
229
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git tag v1.0.0.RELEASE')
|
230
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git checkout --quiet master')
|
231
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:exec).with('git branch --quiet -D pivotal-tracker-release')
|
232
|
+
|
233
|
+
GitPivotalTrackerIntegration::Util::Git.create_release_tag '1.0.0.RELEASE', story
|
234
|
+
end
|
235
|
+
end
|
@@ -0,0 +1,52 @@
|
|
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 'spec_helper'
|
17
|
+
require 'git-pivotal-tracker-integration/util/shell'
|
18
|
+
|
19
|
+
describe GitPivotalTrackerIntegration::Util::Shell do
|
20
|
+
|
21
|
+
before do
|
22
|
+
$stdout = StringIO.new
|
23
|
+
$stderr = StringIO.new
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should return result when exit code is 0' do
|
27
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:`).with('test_command').and_return('test_result')
|
28
|
+
$?.should_receive(:exitstatus).and_return(0)
|
29
|
+
|
30
|
+
result = GitPivotalTrackerIntegration::Util::Shell.exec 'test_command'
|
31
|
+
|
32
|
+
expect(result).to eq('test_result')
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should abort with 'FAIL' when the exit code is not 0" do
|
36
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:`).with('test_command')
|
37
|
+
$?.should_receive(:exitstatus).and_return(-1)
|
38
|
+
|
39
|
+
lambda { GitPivotalTrackerIntegration::Util::Shell.exec 'test_command' }.should raise_error(SystemExit)
|
40
|
+
|
41
|
+
expect($stderr.string).to match(/FAIL/)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should return result when the exit code is not 0 and told not to abort on failure' do
|
45
|
+
GitPivotalTrackerIntegration::Util::Shell.should_receive(:`).with('test_command')
|
46
|
+
$?.should_receive(:exitstatus).and_return(-1)
|
47
|
+
|
48
|
+
GitPivotalTrackerIntegration::Util::Shell.exec 'test_command', false
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,137 @@
|
|
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 'spec_helper'
|
17
|
+
require 'git-pivotal-tracker-integration/util/story'
|
18
|
+
require 'pivotal-tracker'
|
19
|
+
|
20
|
+
describe GitPivotalTrackerIntegration::Util::Story do
|
21
|
+
|
22
|
+
before do
|
23
|
+
$stdout = StringIO.new
|
24
|
+
$stderr = StringIO.new
|
25
|
+
|
26
|
+
@project = double('project')
|
27
|
+
@stories = double('stories')
|
28
|
+
@story = double('story')
|
29
|
+
@menu = double('menu')
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should pretty print story information' do
|
33
|
+
story = double('story')
|
34
|
+
story.should_receive(:name)
|
35
|
+
story.should_receive(:description).and_return("description-1\ndescription-2")
|
36
|
+
PivotalTracker::Note.should_receive(:all).and_return([
|
37
|
+
PivotalTracker::Note.new(:noted_at => Date.new, :text => 'note-1')
|
38
|
+
])
|
39
|
+
|
40
|
+
GitPivotalTrackerIntegration::Util::Story.pretty_print story
|
41
|
+
|
42
|
+
expect($stdout.string).to eq(
|
43
|
+
" Title: \n" +
|
44
|
+
"Description: description-1\n" +
|
45
|
+
" description-2\n" +
|
46
|
+
" Note 1: note-1\n" +
|
47
|
+
"\n")
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should not pretty print description or notes if there are none (empty)' do
|
51
|
+
story = double('story')
|
52
|
+
story.should_receive(:name)
|
53
|
+
story.should_receive(:description)
|
54
|
+
PivotalTracker::Note.should_receive(:all).and_return([])
|
55
|
+
|
56
|
+
GitPivotalTrackerIntegration::Util::Story.pretty_print story
|
57
|
+
|
58
|
+
expect($stdout.string).to eq(
|
59
|
+
" Title: \n" +
|
60
|
+
"\n")
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should not pretty print description or notes if there are none (nil)' do
|
64
|
+
story = double('story')
|
65
|
+
story.should_receive(:name)
|
66
|
+
story.should_receive(:description).and_return('')
|
67
|
+
PivotalTracker::Note.should_receive(:all).and_return([])
|
68
|
+
|
69
|
+
GitPivotalTrackerIntegration::Util::Story.pretty_print story
|
70
|
+
|
71
|
+
expect($stdout.string).to eq(
|
72
|
+
" Title: \n" +
|
73
|
+
"\n")
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should select a story directly if the filter is a number' do
|
77
|
+
@project.should_receive(:stories).and_return(@stories)
|
78
|
+
@stories.should_receive(:find).with(12345678).and_return(@story)
|
79
|
+
|
80
|
+
story = GitPivotalTrackerIntegration::Util::Story.select_story @project, '12345678'
|
81
|
+
|
82
|
+
expect(story).to be(@story)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should select a story if the result of the query is a single story' do
|
86
|
+
@project.should_receive(:stories).and_return(@stories)
|
87
|
+
@stories.should_receive(:all).with(
|
88
|
+
:current_state => %w(rejected unstarted unscheduled),
|
89
|
+
:limit => 1,
|
90
|
+
:story_type => 'release'
|
91
|
+
).and_return([@story])
|
92
|
+
|
93
|
+
story = GitPivotalTrackerIntegration::Util::Story.select_story @project, 'release', 1
|
94
|
+
|
95
|
+
expect(story).to be(@story)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should prompt the user for a story if the result of the query is more than a single story' do
|
99
|
+
@project.should_receive(:stories).and_return(@stories)
|
100
|
+
@stories.should_receive(:all).with(
|
101
|
+
:current_state => %w(rejected unstarted unscheduled),
|
102
|
+
:limit => 5,
|
103
|
+
:story_type => 'feature'
|
104
|
+
).and_return([
|
105
|
+
PivotalTracker::Story.new(:name => 'name-1'),
|
106
|
+
PivotalTracker::Story.new(:name => 'name-2')
|
107
|
+
])
|
108
|
+
@menu.should_receive(:prompt=)
|
109
|
+
@menu.should_receive(:choice).with('name-1')
|
110
|
+
@menu.should_receive(:choice).with('name-2')
|
111
|
+
GitPivotalTrackerIntegration::Util::Story.should_receive(:choose) { |&arg| arg.call @menu }.and_return(@story)
|
112
|
+
|
113
|
+
story = GitPivotalTrackerIntegration::Util::Story.select_story @project, 'feature'
|
114
|
+
|
115
|
+
expect(story).to be(@story)
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should prompt the user with the story type if no filter is specified' do
|
119
|
+
@project.should_receive(:stories).and_return(@stories)
|
120
|
+
@stories.should_receive(:all).with(
|
121
|
+
:current_state => %w(rejected unstarted unscheduled),
|
122
|
+
:limit => 5
|
123
|
+
).and_return([
|
124
|
+
PivotalTracker::Story.new(:story_type => 'chore', :name => 'name-1'),
|
125
|
+
PivotalTracker::Story.new(:story_type => 'bug', :name => 'name-2')
|
126
|
+
])
|
127
|
+
@menu.should_receive(:prompt=)
|
128
|
+
@menu.should_receive(:choice).with('CHORE name-1')
|
129
|
+
@menu.should_receive(:choice).with('BUG name-2')
|
130
|
+
GitPivotalTrackerIntegration::Util::Story.should_receive(:choose) { |&arg| arg.call @menu }.and_return(@story)
|
131
|
+
|
132
|
+
story = GitPivotalTrackerIntegration::Util::Story.select_story @project
|
133
|
+
|
134
|
+
expect(story).to be(@story)
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|