git-process 1.1.4 → 2.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/CHANGELOG.md +14 -1
- data/LICENSE +193 -22
- data/README.md +212 -71
- data/man/git-process.1 +371 -0
- metadata +52 -140
- data/Gemfile +0 -20
- data/Gemfile.lock +0 -53
- data/Rakefile +0 -16
- data/bin/git-new-fb +0 -58
- data/bin/git-pull-request +0 -107
- data/bin/git-sync +0 -73
- data/bin/git-to-master +0 -133
- data/git-process.gemspec +0 -25
- data/lib/git-process/abstract_error_builder.rb +0 -53
- data/lib/git-process/changed_file_helper.rb +0 -115
- data/lib/git-process/git_abstract_merge_error_builder.rb +0 -146
- data/lib/git-process/git_branch.rb +0 -105
- data/lib/git-process/git_branches.rb +0 -73
- data/lib/git-process/git_config.rb +0 -153
- data/lib/git-process/git_lib.rb +0 -512
- data/lib/git-process/git_logger.rb +0 -84
- data/lib/git-process/git_merge_error.rb +0 -28
- data/lib/git-process/git_process.rb +0 -172
- data/lib/git-process/git_process_error.rb +0 -18
- data/lib/git-process/git_process_options.rb +0 -99
- data/lib/git-process/git_rebase_error.rb +0 -30
- data/lib/git-process/git_remote.rb +0 -256
- data/lib/git-process/git_status.rb +0 -108
- data/lib/git-process/github_configuration.rb +0 -298
- data/lib/git-process/github_pull_request.rb +0 -151
- data/lib/git-process/new_fb.rb +0 -50
- data/lib/git-process/parked_changes_error.rb +0 -41
- data/lib/git-process/pull_request.rb +0 -134
- data/lib/git-process/pull_request_error.rb +0 -25
- data/lib/git-process/rebase_to_master.rb +0 -148
- data/lib/git-process/sync.rb +0 -136
- data/lib/git-process/uncommitted_changes_error.rb +0 -23
- data/lib/git-process/version.rb +0 -22
- data/spec/FileHelpers.rb +0 -19
- data/spec/GitRepoHelper.rb +0 -123
- data/spec/changed_file_helper_spec.rb +0 -127
- data/spec/git_abstract_merge_error_builder_spec.rb +0 -126
- data/spec/git_branch_spec.rb +0 -123
- data/spec/git_config_spec.rb +0 -45
- data/spec/git_lib_spec.rb +0 -176
- data/spec/git_logger_spec.rb +0 -66
- data/spec/git_process_spec.rb +0 -208
- data/spec/git_remote_spec.rb +0 -227
- data/spec/git_status_spec.rb +0 -122
- data/spec/github_configuration_spec.rb +0 -152
- data/spec/github_pull_request_spec.rb +0 -96
- data/spec/github_test_helper.rb +0 -49
- data/spec/new_fb_spec.rb +0 -130
- data/spec/pull_request_helper.rb +0 -94
- data/spec/pull_request_spec.rb +0 -128
- data/spec/rebase_to_master_spec.rb +0 -429
- data/spec/spec_helper.rb +0 -21
- data/spec/sync_spec.rb +0 -304
@@ -1,429 +0,0 @@
|
|
1
|
-
require 'git-process/rebase_to_master'
|
2
|
-
require 'GitRepoHelper'
|
3
|
-
require 'github_test_helper'
|
4
|
-
require 'pull_request_helper'
|
5
|
-
require 'webmock/rspec'
|
6
|
-
require 'json'
|
7
|
-
include GitProc
|
8
|
-
|
9
|
-
describe RebaseToMaster do
|
10
|
-
include GitRepoHelper
|
11
|
-
include GitHubTestHelper
|
12
|
-
|
13
|
-
|
14
|
-
def log_level
|
15
|
-
Logger::ERROR
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
before(:each) do
|
20
|
-
create_files(%w(.gitignore))
|
21
|
-
gitlib.commit('initial')
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
after(:each) do
|
26
|
-
rm_rf(gitlib.workdir)
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
def create_process(base, opts = {})
|
31
|
-
RebaseToMaster.new(base, opts)
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
describe 'rebase to master' do
|
36
|
-
|
37
|
-
it "should work easily for a simple rebase" do
|
38
|
-
gitlib.checkout('fb', :new_branch => 'master')
|
39
|
-
change_file_and_commit('a', '')
|
40
|
-
|
41
|
-
commit_count.should == 2
|
42
|
-
|
43
|
-
gitlib.checkout('master')
|
44
|
-
change_file_and_commit('b', '')
|
45
|
-
|
46
|
-
gitlib.checkout('fb')
|
47
|
-
|
48
|
-
gitprocess.run
|
49
|
-
|
50
|
-
commit_count.should == 3
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
it 'should work for a rebase after a rerere merge' do
|
55
|
-
# Make sure rerere is enabled
|
56
|
-
config.rerere_enabled(true, false)
|
57
|
-
config.rerere_autoupdate(false, false)
|
58
|
-
|
59
|
-
# Create the file to conflict on
|
60
|
-
change_file_and_commit('a', '')
|
61
|
-
|
62
|
-
# In the new branch, give it a new value
|
63
|
-
gitlib.checkout('fb', :new_branch => 'master') do
|
64
|
-
change_file_and_commit('a', 'hello')
|
65
|
-
end
|
66
|
-
|
67
|
-
# Change the value as well in the original branch
|
68
|
-
gitlib.checkout('master') do
|
69
|
-
change_file_and_commit('a', 'goodbye')
|
70
|
-
end
|
71
|
-
|
72
|
-
# Merge in the new branch; don't error-out because will auto-fix.
|
73
|
-
gitlib.checkout('fb') do
|
74
|
-
gitlib.merge('master') rescue
|
75
|
-
change_file_and_commit('a', 'merged')
|
76
|
-
end
|
77
|
-
|
78
|
-
# Make another change on master
|
79
|
-
gitlib.checkout('master') do
|
80
|
-
change_file_and_commit('b', '')
|
81
|
-
end
|
82
|
-
|
83
|
-
# Go back to the branch and try to rebase
|
84
|
-
gitlib.checkout('fb')
|
85
|
-
|
86
|
-
begin
|
87
|
-
gitprocess.runner
|
88
|
-
raise "Should have raised RebaseError"
|
89
|
-
rescue RebaseError => exp
|
90
|
-
error_builder = exp.error_builder
|
91
|
-
error_builder.resolved_files.should == %w(a)
|
92
|
-
error_builder.unresolved_files.should == []
|
93
|
-
|
94
|
-
error_builder.commands.length.should == 3
|
95
|
-
error_builder.commands[0].should match /^# Verify/
|
96
|
-
error_builder.commands[1].should == 'git add a'
|
97
|
-
error_builder.commands[2].should == 'git rebase --continue'
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
|
102
|
-
describe "when used on _parking_" do
|
103
|
-
it 'should fail #rebase_to_master' do
|
104
|
-
gitlib.checkout('_parking_', :new_branch => 'master')
|
105
|
-
change_file_and_commit('a', '')
|
106
|
-
|
107
|
-
expect { gitprocess.verify_preconditions }.to raise_error ParkedChangesError
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
|
112
|
-
describe "closing the pull request" do
|
113
|
-
include PullRequestHelper
|
114
|
-
|
115
|
-
|
116
|
-
def pull_request
|
117
|
-
@pr ||= create_pull_request(:pr_number => '987', :head_branch => 'fb', :base_branch => 'master')
|
118
|
-
end
|
119
|
-
|
120
|
-
|
121
|
-
it "should not try when there is no auth token" do
|
122
|
-
gitlib.branch('fb', :base_branch => 'master')
|
123
|
-
clone_repo('fb') do |gl|
|
124
|
-
gl.config['gitProcess.github.authToken'] = ''
|
125
|
-
gl.config['remote.origin.url'] = 'git@github.com:test_repo.git'
|
126
|
-
gl.config['github.user'] = 'test_user'
|
127
|
-
|
128
|
-
rtm = RebaseToMaster.new(gl, :log_level => log_level)
|
129
|
-
rtm.gitlib.stub(:fetch)
|
130
|
-
rtm.gitlib.stub(:push)
|
131
|
-
rtm.runner
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
end
|
136
|
-
|
137
|
-
end
|
138
|
-
|
139
|
-
|
140
|
-
describe "custom integration branch" do
|
141
|
-
|
142
|
-
it "should use the 'gitProcess.integrationBranch' configuration" do
|
143
|
-
gitlib.checkout('int-br', :new_branch => 'master')
|
144
|
-
change_file_and_commit('a', '')
|
145
|
-
|
146
|
-
gitlib.checkout('fb', :new_branch => 'master')
|
147
|
-
change_file_and_commit('b', '')
|
148
|
-
|
149
|
-
gitlib.branches['master'].delete!
|
150
|
-
|
151
|
-
clone_repo('int-br') do |gl|
|
152
|
-
gl.config['gitProcess.integrationBranch'] = 'int-br'
|
153
|
-
|
154
|
-
gl.checkout('ab', :new_branch => 'origin/int-br')
|
155
|
-
|
156
|
-
my_branches = gl.branches
|
157
|
-
my_branches.include?('origin/master').should be_false
|
158
|
-
my_branches['ab'].sha.should == my_branches['origin/int-br'].sha
|
159
|
-
|
160
|
-
gl.stub(:repo_name).and_return('test_repo')
|
161
|
-
|
162
|
-
change_file_and_commit('c', '', gl)
|
163
|
-
|
164
|
-
my_branches = gl.branches
|
165
|
-
my_branches['ab'].sha.should_not == my_branches['origin/int-br'].sha
|
166
|
-
|
167
|
-
RebaseToMaster.new(gl, :log_level => log_level).runner
|
168
|
-
|
169
|
-
my_branches = gl.branches
|
170
|
-
my_branches['HEAD'].sha.should == my_branches['origin/int-br'].sha
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
end
|
175
|
-
|
176
|
-
|
177
|
-
describe "remove current feature branch" do
|
178
|
-
|
179
|
-
describe "when handling the parking branch" do
|
180
|
-
|
181
|
-
it "should create it based on origin/master" do
|
182
|
-
gitlib.branch('fb', :base_branch => 'master')
|
183
|
-
clone_repo('fb') do |gl|
|
184
|
-
create_process(gl).remove_feature_branch
|
185
|
-
gl.branches.current.name.should == '_parking_'
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
|
190
|
-
it "should move it to the new origin/master if it already exists and is clean" do
|
191
|
-
clone_repo do |gl|
|
192
|
-
gl.branch('_parking_', :base_branch => 'origin/master')
|
193
|
-
change_file_and_commit('a', '', gl)
|
194
|
-
|
195
|
-
gl.checkout('fb', :new_branch => 'origin/master')
|
196
|
-
|
197
|
-
create_process(gl).remove_feature_branch
|
198
|
-
|
199
|
-
gl.branches.current.name.should == '_parking_'
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
|
204
|
-
it "should move it to the new origin/master if it already exists and changes are part of the current branch" do
|
205
|
-
gitlib.checkout('afb', :new_branch => 'master')
|
206
|
-
clone_repo do |gl|
|
207
|
-
gl.checkout('_parking_', :new_branch => 'origin/master') do
|
208
|
-
change_file_and_commit('a', '', gl)
|
209
|
-
end
|
210
|
-
|
211
|
-
gl.checkout('fb', :new_branch => '_parking_')
|
212
|
-
gl.push('origin', 'fb', 'master')
|
213
|
-
|
214
|
-
create_process(gl).remove_feature_branch
|
215
|
-
gl.branches.current.name.should == '_parking_'
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
|
220
|
-
it "should move it out of the way if it has unaccounted changes on it" do
|
221
|
-
clone_repo do |gl|
|
222
|
-
gl.checkout('_parking_', :new_branch => 'origin/master')
|
223
|
-
change_file_and_commit('a', '', gl)
|
224
|
-
gl.checkout('fb', :new_branch => 'origin/master')
|
225
|
-
|
226
|
-
gl.branches.include?('_parking_OLD_').should be_false
|
227
|
-
|
228
|
-
create_process(gl).remove_feature_branch
|
229
|
-
|
230
|
-
gl.branches.include?('_parking_OLD_').should be_true
|
231
|
-
gl.branches.current.name.should == '_parking_'
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
end
|
236
|
-
|
237
|
-
|
238
|
-
it "should delete the old local branch when it has been merged into origin/master" do
|
239
|
-
clone_repo do |gl|
|
240
|
-
change_file_and_commit('a', '', gl)
|
241
|
-
|
242
|
-
gl.checkout('fb', :new_branch => 'origin/master')
|
243
|
-
gl.branches.include?('fb').should be_true
|
244
|
-
|
245
|
-
create_process(gl).remove_feature_branch
|
246
|
-
|
247
|
-
gl.branches.include?('fb').should be_false
|
248
|
-
gl.branches.current.name.should == '_parking_'
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
|
253
|
-
it "should raise an error when the local branch has not been merged into origin/master" do
|
254
|
-
clone_repo do |gl|
|
255
|
-
gl.checkout('fb', :new_branch => 'origin/master')
|
256
|
-
change_file_and_commit('a', '', gl)
|
257
|
-
|
258
|
-
gl.branches.include?('fb').should be_true
|
259
|
-
|
260
|
-
expect { create_process(gl).remove_feature_branch }.to raise_error GitProcessError
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
|
265
|
-
it "should delete the old remote branch" do
|
266
|
-
change_file_and_commit('a', '')
|
267
|
-
|
268
|
-
gitlib.branch('fb', :base_branch => 'master')
|
269
|
-
|
270
|
-
clone_repo('fb') do |gl|
|
271
|
-
gl.branches.include?('origin/fb').should be_true
|
272
|
-
create_process(gl).remove_feature_branch
|
273
|
-
gl.branches.include?('origin/fb').should be_false
|
274
|
-
gitlib.branches.include?('fb').should be_false
|
275
|
-
gl.branches.current.name.should == '_parking_'
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
end
|
280
|
-
|
281
|
-
|
282
|
-
describe ":keep option" do
|
283
|
-
|
284
|
-
it "should not try to close a pull request or remove remote branch" do
|
285
|
-
gitlib.branch('fb', :base_branch => 'master')
|
286
|
-
|
287
|
-
clone_repo('fb') do |gl|
|
288
|
-
rtm = GitProc::RebaseToMaster.new(gl, :log_level => log_level, :keep => true)
|
289
|
-
gl.should_receive(:fetch)
|
290
|
-
gl.should_receive(:push).with('origin', gl.branches.current.name, 'master')
|
291
|
-
gl.should_not_receive(:push).with('origin', nil, nil, :delete => 'fb')
|
292
|
-
rtm.runner
|
293
|
-
end
|
294
|
-
end
|
295
|
-
|
296
|
-
end
|
297
|
-
|
298
|
-
|
299
|
-
describe ":interactive option" do
|
300
|
-
|
301
|
-
it "should try to do an interactive rebase" do
|
302
|
-
gitlib.branch('fb', :base_branch => 'master')
|
303
|
-
|
304
|
-
clone_repo('fb') do |gl|
|
305
|
-
rtm = GitProc::RebaseToMaster.new(gl, :log_level => log_level, :interactive => true)
|
306
|
-
gl.should_receive(:fetch)
|
307
|
-
gl.should_receive(:rebase).with('origin/master', {})
|
308
|
-
gl.should_receive(:rebase).with('origin/master', :interactive => true)
|
309
|
-
gl.should_receive(:push).with('origin', gl.branches.current.name, 'master')
|
310
|
-
gl.should_receive(:push).with('origin', nil, nil, :delete => 'fb')
|
311
|
-
rtm.runner
|
312
|
-
end
|
313
|
-
end
|
314
|
-
|
315
|
-
end
|
316
|
-
|
317
|
-
|
318
|
-
describe 'to-master pull request' do
|
319
|
-
include PullRequestHelper
|
320
|
-
|
321
|
-
|
322
|
-
def pull_request_number
|
323
|
-
pull_request[:number]
|
324
|
-
end
|
325
|
-
|
326
|
-
|
327
|
-
def head_repo_name
|
328
|
-
pull_request[:head][:repo][:name]
|
329
|
-
end
|
330
|
-
|
331
|
-
|
332
|
-
def base_repo_name
|
333
|
-
pull_request[:base][:repo][:name]
|
334
|
-
end
|
335
|
-
|
336
|
-
|
337
|
-
def base_branch_name
|
338
|
-
pull_request[:base][:ref]
|
339
|
-
end
|
340
|
-
|
341
|
-
|
342
|
-
def head_branch_name
|
343
|
-
pull_request[:head][:ref]
|
344
|
-
end
|
345
|
-
|
346
|
-
|
347
|
-
before(:each) do
|
348
|
-
gitlib.branch(head_branch_name, :base_branch => 'master')
|
349
|
-
end
|
350
|
-
|
351
|
-
|
352
|
-
def configure(gl)
|
353
|
-
gl.config['gitProcess.github.authToken'] = 'sdfsfsdf'
|
354
|
-
gl.config["remote.#{head_repo_name}.url"] = "git@github.com:#{head_repo_name}.git"
|
355
|
-
gl.config['github.user'] = 'jdigger'
|
356
|
-
gl.config['gitProcess.remoteName'] = head_repo_name
|
357
|
-
|
358
|
-
stub_fetch(:head, gl)
|
359
|
-
stub_fetch(:base, gl)
|
360
|
-
|
361
|
-
stub_get("https://api.github.com/repos/#{head_repo_name}/pulls/#{pull_request_number}", :body => pull_request)
|
362
|
-
stub_patch("https://api.github.com/repos/#{head_repo_name}/pulls/#{pull_request_number}")
|
363
|
-
end
|
364
|
-
|
365
|
-
|
366
|
-
describe "with PR #" do
|
367
|
-
|
368
|
-
def pull_request
|
369
|
-
@pr ||= create_pull_request({})
|
370
|
-
end
|
371
|
-
|
372
|
-
|
373
|
-
def create_process(dir, opts)
|
374
|
-
RebaseToMaster.new(dir, opts.merge({:prNumber => pull_request_number}))
|
375
|
-
end
|
376
|
-
|
377
|
-
|
378
|
-
it "should checkout the branch for the pull request" do
|
379
|
-
clone_repo('master', head_repo_name) do |gl|
|
380
|
-
gl.branch("#{base_repo_name}/#{base_branch_name}", :base_branch => "#{head_repo_name}/master")
|
381
|
-
|
382
|
-
configure(gl)
|
383
|
-
|
384
|
-
rtm = GitProc::RebaseToMaster.new(gl, :log_level => log_level, :prNumber => pull_request_number)
|
385
|
-
|
386
|
-
gl.should_receive(:push).with(head_repo_name, head_branch_name, 'master')
|
387
|
-
gl.should_receive(:push).with(head_repo_name, nil, nil, :delete => head_branch_name)
|
388
|
-
|
389
|
-
rtm.runner
|
390
|
-
end
|
391
|
-
end
|
392
|
-
|
393
|
-
end
|
394
|
-
|
395
|
-
|
396
|
-
describe "with repo name and PR #" do
|
397
|
-
|
398
|
-
def pull_request
|
399
|
-
@pr ||= create_pull_request(:base_remote => 'sourcerepo', :base_repo => 'source_repo')
|
400
|
-
end
|
401
|
-
|
402
|
-
|
403
|
-
def create_process(dir, opts = {})
|
404
|
-
RebaseToMaster.new(dir, opts.merge({:prNumber => var,
|
405
|
-
:server => pull_request[:head][:remote]}))
|
406
|
-
end
|
407
|
-
|
408
|
-
|
409
|
-
it "should checkout the branch for the pull request" do
|
410
|
-
clone_repo('master', head_repo_name) do |gl|
|
411
|
-
add_remote(:base, gl)
|
412
|
-
gl.branch("#{base_repo_name}/#{base_branch_name}", :base_branch => "#{head_repo_name}/master")
|
413
|
-
|
414
|
-
configure(gl)
|
415
|
-
|
416
|
-
rtm = GitProc::RebaseToMaster.new(gl, :log_level => log_level, :prNumber => pull_request_number)
|
417
|
-
|
418
|
-
gl.should_receive(:push).with(head_repo_name, head_branch_name, 'master')
|
419
|
-
gl.should_receive(:push).with(head_repo_name, nil, nil, :delete => head_branch_name)
|
420
|
-
|
421
|
-
rtm.runner
|
422
|
-
end
|
423
|
-
end
|
424
|
-
|
425
|
-
end
|
426
|
-
|
427
|
-
end
|
428
|
-
|
429
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '../lib')
|
2
|
-
|
3
|
-
require 'GitRepoHelper'
|
4
|
-
require 'pull_request_helper'
|
5
|
-
|
6
|
-
RSpec.configure do |config|
|
7
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
8
|
-
|
9
|
-
config.include GitRepoHelper, :git_repo_helper
|
10
|
-
|
11
|
-
config.before(:each, :git_repo_helper) do
|
12
|
-
create_files(%w(.gitignore))
|
13
|
-
gitlib.commit('initial')
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
config.after(:each, :git_repo_helper) do
|
18
|
-
rm_rf(gitlib.workdir)
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|