git_reflow 0.7.5 → 0.8.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Appraisals +2 -2
- data/CHANGELOG.md +75 -0
- data/Gemfile.lock +34 -35
- data/README.rdoc +187 -60
- data/circle.yml +9 -9
- data/git_reflow.gemspec +8 -8
- data/lib/git_reflow/commands/deliver.rb +1 -9
- data/lib/git_reflow/commands/refresh.rb +23 -0
- data/lib/git_reflow/commands/review.rb +7 -7
- data/lib/git_reflow/commands/setup.rb +7 -3
- data/lib/git_reflow/commands/start.rb +13 -5
- data/lib/git_reflow/git_helpers.rb +22 -23
- data/lib/git_reflow/git_server/bit_bucket/pull_request.rb +4 -4
- data/lib/git_reflow/git_server/bit_bucket.rb +7 -7
- data/lib/git_reflow/git_server/git_hub/pull_request.rb +75 -2
- data/lib/git_reflow/git_server/git_hub.rb +17 -8
- data/lib/git_reflow/git_server/pull_request.rb +73 -5
- data/lib/git_reflow/git_server.rb +3 -3
- data/lib/git_reflow/merge_error.rb +9 -0
- data/lib/git_reflow/sandbox.rb +4 -16
- data/lib/git_reflow/version.rb +1 -1
- data/lib/git_reflow.rb +32 -75
- data/spec/git_reflow_spec.rb +157 -141
- data/spec/lgtm_git_reflow_spec.rb +165 -139
- data/spec/lib/git_reflow/git_helpers_spec.rb +19 -63
- data/spec/lib/git_reflow/git_server_spec.rb +24 -24
- data/spec/lib/git_server/bit_bucket_spec.rb +12 -12
- data/spec/lib/git_server/git_hub/pull_request_spec.rb +7 -5
- data/spec/lib/git_server/git_hub_spec.rb +34 -34
- data/spec/lib/git_server/pull_request_spec.rb +207 -16
- data/spec/support/command_line_helpers.rb +14 -9
- data/spec/support/github_helpers.rb +21 -21
- data/spec/support/rspec_stub_helpers.rb +2 -2
- metadata +18 -16
@@ -5,6 +5,10 @@ describe GitReflow::GitServer::PullRequest do
|
|
5
5
|
let(:github) { stub_github_with({ user: 'reenhanced', repo: 'repo', pull: pull_request }) }
|
6
6
|
let!(:github_api) { github.connection }
|
7
7
|
let(:git_server) { GitReflow::GitServer::GitHub.new {} }
|
8
|
+
let(:user) { 'reenhanced' }
|
9
|
+
let(:password) { 'shazam' }
|
10
|
+
let(:enterprise_site) { 'https://github.reenhanced.com' }
|
11
|
+
let(:enterprise_api) { 'https://github.reenhanced.com' }
|
8
12
|
|
9
13
|
describe "#good_to_merge?(options)" do
|
10
14
|
subject { GitReflow::GitServer::GitHub::PullRequest.new(pull_request) }
|
@@ -20,11 +24,11 @@ describe GitReflow::GitServer::PullRequest do
|
|
20
24
|
})
|
21
25
|
# setup initial valid state
|
22
26
|
allow_any_instance_of(GitReflow::GitServer::GitHub::PullRequest).to receive(:build).and_return(Struct.new(:state, :description, :url).new)
|
23
|
-
GitReflow.git_server.
|
27
|
+
allow(GitReflow.git_server).to receive(:find_open_pull_request).with({from: 'new-feature', to: 'master'}).and_return(pull_request)
|
24
28
|
|
25
29
|
# stubs approvals and last_comment conditions to default to true
|
26
|
-
pull_request.
|
27
|
-
pull_request.
|
30
|
+
allow(pull_request).to receive(:approvals).and_return(["Simon", "John"])
|
31
|
+
allow(pull_request).to receive_message_chain(:last_comment, :match).and_return(true)
|
28
32
|
allow(GitReflow::GitServer::PullRequest).to receive(:minimum_approvals).and_return("2")
|
29
33
|
allow(GitReflow::GitServer::PullRequest).to receive(:approval_regex).and_return(/(?i-mx:lgtm|looks good to me|:\+1:|:thumbsup:|:shipit:)/)
|
30
34
|
|
@@ -250,7 +254,7 @@ describe GitReflow::GitServer::PullRequest do
|
|
250
254
|
allow(subject).to receive(:build_status).and_return('failure')
|
251
255
|
end
|
252
256
|
|
253
|
-
specify { subject.rejection_message.
|
257
|
+
specify { expect(subject.rejection_message).to eq(": ") }
|
254
258
|
end
|
255
259
|
|
256
260
|
context "Testing Minimum Approvals Failure" do
|
@@ -259,7 +263,7 @@ describe GitReflow::GitServer::PullRequest do
|
|
259
263
|
allow(subject).to receive(:approval_minimums_reached?).and_return(false)
|
260
264
|
allow(GitReflow::GitServer::PullRequest).to receive(:minimum_approvals).and_return("2")
|
261
265
|
end
|
262
|
-
specify { subject.rejection_message.
|
266
|
+
specify { expect(subject.rejection_message).to eq("You need approval from at least 2 users!") }
|
263
267
|
end
|
264
268
|
|
265
269
|
context "Testing Minimum Approvals Reached" do
|
@@ -268,7 +272,7 @@ describe GitReflow::GitServer::PullRequest do
|
|
268
272
|
allow(subject).to receive(:all_comments_addressed?).and_return(false)
|
269
273
|
allow(subject).to receive(:last_comment).and_return("Hello")
|
270
274
|
end
|
271
|
-
specify { subject.rejection_message.
|
275
|
+
specify { expect(subject.rejection_message).to eq("The last comment is holding up approval:\nHello") }
|
272
276
|
end
|
273
277
|
|
274
278
|
context "Testing All Comments Addressed" do
|
@@ -277,7 +281,7 @@ describe GitReflow::GitServer::PullRequest do
|
|
277
281
|
allow(subject).to receive(:all_comments_addressed?).and_return(false)
|
278
282
|
allow(subject).to receive(:last_comment).and_return("Hello")
|
279
283
|
end
|
280
|
-
specify { subject.rejection_message.
|
284
|
+
specify { expect(subject.rejection_message).to eq("The last comment is holding up approval:\nHello") }
|
281
285
|
end
|
282
286
|
|
283
287
|
context "Testing All Comments Addressed" do
|
@@ -287,7 +291,7 @@ describe GitReflow::GitServer::PullRequest do
|
|
287
291
|
allow(subject).to receive(:all_comments_addressed?).and_return(true)
|
288
292
|
allow(subject).to receive(:approval_minimums_reached?).and_return(true)
|
289
293
|
end
|
290
|
-
specify { subject.rejection_message.
|
294
|
+
specify { expect(subject.rejection_message).to eq( "You still need a LGTM from: Simon") }
|
291
295
|
end
|
292
296
|
|
293
297
|
context "Testing Last Case" do
|
@@ -297,7 +301,7 @@ describe GitReflow::GitServer::PullRequest do
|
|
297
301
|
allow(subject).to receive(:all_comments_addressed?).and_return(true)
|
298
302
|
allow(subject).to receive(:approval_minimums_reached?).and_return(true)
|
299
303
|
end
|
300
|
-
specify { subject.rejection_message.
|
304
|
+
specify { expect(subject.rejection_message).to eq("Your code has not been reviewed yet.") }
|
301
305
|
end
|
302
306
|
end
|
303
307
|
|
@@ -313,7 +317,7 @@ describe GitReflow::GitServer::PullRequest do
|
|
313
317
|
allow(subject).to receive(:minimum_approvals).and_return('2')
|
314
318
|
allow(subject).to receive(:approvals).and_return(['Simon'])
|
315
319
|
end
|
316
|
-
specify { subject.approval_minimums_reached
|
320
|
+
specify { expect(subject.approval_minimums_reached?).to eq(true) }
|
317
321
|
end
|
318
322
|
|
319
323
|
context "Testing a Success Case" do
|
@@ -321,7 +325,7 @@ describe GitReflow::GitServer::PullRequest do
|
|
321
325
|
allow(subject).to receive(:minimum_approvals).and_return('2')
|
322
326
|
allow(subject).to receive(:approvals).and_return(['Simon', 'John'])
|
323
327
|
end
|
324
|
-
specify { subject.approval_minimums_reached
|
328
|
+
specify { expect(subject.approval_minimums_reached?).to eq(true) }
|
325
329
|
end
|
326
330
|
|
327
331
|
context "Testing Case with no minimum_approval" do
|
@@ -329,7 +333,7 @@ describe GitReflow::GitServer::PullRequest do
|
|
329
333
|
allow(subject).to receive(:minimum_approvals).and_return('')
|
330
334
|
allow(subject).to receive(:approvals).and_return([])
|
331
335
|
end
|
332
|
-
specify { subject.approval_minimums_reached
|
336
|
+
specify { expect(subject.approval_minimums_reached?).to eq(true) }
|
333
337
|
end
|
334
338
|
end
|
335
339
|
|
@@ -347,11 +351,11 @@ describe GitReflow::GitServer::PullRequest do
|
|
347
351
|
comments: [{author: 'tito', body: 'lgtm'}, {author: 'ringo', body: ':+1:'}]
|
348
352
|
})
|
349
353
|
allow_any_instance_of(GitReflow::GitServer::GitHub::PullRequest).to receive(:build).and_return(Struct.new(:state, :description, :url).new)
|
350
|
-
GitReflow.git_server.
|
354
|
+
allow(GitReflow.git_server).to receive(:find_open_pull_request).with({from: 'new-external-feature', to: 'master'}).and_return(pull_request)
|
351
355
|
end
|
352
356
|
|
353
357
|
it "displays relavent information about the pull request" do
|
354
|
-
expect{ subject }.to have_output("branches: new-external-feature ->
|
358
|
+
expect{ subject }.to have_output("branches: new-external-feature -> master")
|
355
359
|
expect{ subject }.to have_output("number: #{pull_request.number}")
|
356
360
|
expect{ subject }.to have_output("url: #{pull_request.html_url}")
|
357
361
|
expect{ subject }.to have_output("reviewed by: #{"tito".colorize(:green)}, #{"ringo".colorize(:green)}")
|
@@ -377,11 +381,11 @@ describe GitReflow::GitServer::PullRequest do
|
|
377
381
|
]
|
378
382
|
})
|
379
383
|
allow_any_instance_of(GitReflow::GitServer::GitHub::PullRequest).to receive(:build).and_return(Struct.new(:state, :description, :url).new)
|
380
|
-
GitReflow.git_server.
|
384
|
+
allow(GitReflow.git_server).to receive(:find_open_pull_request).with({from: 'new-external-feature', to: 'master'}).and_return(pull_request)
|
381
385
|
end
|
382
386
|
|
383
387
|
it "displays relavent information about the pull request" do
|
384
|
-
expect{ subject }.to have_output("branches: new-external-feature ->
|
388
|
+
expect{ subject }.to have_output("branches: new-external-feature -> master")
|
385
389
|
expect{ subject }.to have_output("number: #{pull_request.number}")
|
386
390
|
expect{ subject }.to have_output("url: #{pull_request.html_url}")
|
387
391
|
expect{ subject }.to have_output("reviewed by: #{"tito".colorize(:green)}, #{"ringo".colorize(:green)}, #{"Simon".colorize(:green)}, #{"Peter".colorize(:green)}, #{"Johnny".colorize(:green)}, #{"Jacob".colorize(:green)}")
|
@@ -389,4 +393,191 @@ describe GitReflow::GitServer::PullRequest do
|
|
389
393
|
end
|
390
394
|
end
|
391
395
|
end
|
396
|
+
|
397
|
+
context ".merge!" do
|
398
|
+
subject { GitReflow::GitServer::GitHub::PullRequest.new(pull_request) }
|
399
|
+
|
400
|
+
let(:inputs) {
|
401
|
+
{
|
402
|
+
:base => "base_branch",
|
403
|
+
:title => "title",
|
404
|
+
:message => "message"
|
405
|
+
}
|
406
|
+
}
|
407
|
+
|
408
|
+
let(:lgtm_comment_authors) {
|
409
|
+
["simonzhu24", "reenhanced"]
|
410
|
+
}
|
411
|
+
|
412
|
+
let(:merge_response) { { :message => "Failure_Message" } }
|
413
|
+
|
414
|
+
context "finds pull request but merge response fails" do
|
415
|
+
before do
|
416
|
+
allow(GitReflow).to receive(:git_server).and_return(git_server)
|
417
|
+
allow(git_server).to receive(:connection).and_return(github)
|
418
|
+
allow(git_server).to receive(:get_build_status).and_return(Struct.new(:state, :description, :target_url).new())
|
419
|
+
allow(GitReflow::GitServer::GitHub).to receive_message_chain(:connection, :pull_requests, :merge).and_return(merge_response)
|
420
|
+
allow(merge_response).to receive(:success?).and_return(false)
|
421
|
+
allow_any_instance_of(GitReflow::GitServer::GitHub::PullRequest).to receive(:approvals).and_return(lgtm_comment_authors)
|
422
|
+
allow(subject).to receive(:deliver?).and_return(true)
|
423
|
+
allow(merge_response).to receive(:to_s).and_return("Merge failed")
|
424
|
+
end
|
425
|
+
|
426
|
+
it "throws an error" do
|
427
|
+
expect { subject.merge! inputs }.to have_said "Merge failed", :deliver_halted
|
428
|
+
expect { subject.merge! inputs }.to have_said "There were problems commiting your feature... please check the errors above and try again.", :error
|
429
|
+
end
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
context ".commit_message_for_merge" do
|
434
|
+
subject { GitReflow::GitServer::GitHub::PullRequest.new(pull_request) }
|
435
|
+
|
436
|
+
let(:lgtm_comment_authors) {
|
437
|
+
["simonzhu24", "reenhanced"]
|
438
|
+
}
|
439
|
+
|
440
|
+
let(:output) { lgtm_comment_authors.join(', @') }
|
441
|
+
|
442
|
+
context "checks commit message generated is correct" do
|
443
|
+
before do
|
444
|
+
allow_any_instance_of(GitReflow::GitServer::GitHub::PullRequest).to receive(:build).and_return(Struct.new(:state, :description, :url).new)
|
445
|
+
allow_any_instance_of(GitReflow::GitServer::GitHub::PullRequest).to receive(:description).and_return("Description")
|
446
|
+
allow_any_instance_of(GitReflow::GitServer::GitHub::PullRequest).to receive(:number).and_return(1)
|
447
|
+
allow_any_instance_of(GitReflow::GitServer::GitHub::PullRequest).to receive(:approvals).and_return(lgtm_comment_authors)
|
448
|
+
end
|
449
|
+
|
450
|
+
it "throws an exception without message" do
|
451
|
+
expect(subject.commit_message_for_merge).to eq("Description\nMerges #1\n\nLGTM given by: @simonzhu24, @reenhanced\n\n")
|
452
|
+
end
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
context :cleanup_feature_branch? do
|
457
|
+
subject { GitReflow::GitServer::GitHub::PullRequest.new(pull_request).cleanup_feature_branch? }
|
458
|
+
|
459
|
+
before do
|
460
|
+
allow(GitReflow::Config).to receive(:get).with("reflow.always-cleanup").and_return("false")
|
461
|
+
allow_any_instance_of(GitReflow::GitServer::GitHub::PullRequest).to receive(:build).and_return(Struct.new(:state, :description, :url).new)
|
462
|
+
FakeGitHub.new(
|
463
|
+
repo_owner: 'reenhanced',
|
464
|
+
repo_name: 'repo',
|
465
|
+
pull_request: {
|
466
|
+
number: pull_request.number,
|
467
|
+
owner: pull_request.head.user.login,
|
468
|
+
comments: [{author: 'tito', body: 'lgtm'}, {author: 'ringo', body: ':+1:'}]
|
469
|
+
})
|
470
|
+
end
|
471
|
+
|
472
|
+
context "doesn't cleanup feature branch" do
|
473
|
+
before do
|
474
|
+
allow_any_instance_of(HighLine).to receive(:ask) do |terminal, question|
|
475
|
+
values = {
|
476
|
+
"Please enter your GitHub username: " => user,
|
477
|
+
"Please enter your GitHub password (we do NOT store this): " => password,
|
478
|
+
"Please enter your Enterprise site URL (e.g. https://github.company.com):" => enterprise_site,
|
479
|
+
"Please enter your Enterprise API endpoint (e.g. https://github.company.com/api/v3):" => enterprise_api,
|
480
|
+
"Would you like to push this branch to your remote repo and cleanup your feature branch? " => 'no',
|
481
|
+
"Would you like to open it in your browser?" => 'n',
|
482
|
+
"This is the current status of your Pull Request. Are you sure you want to deliver? " => 'n',
|
483
|
+
"Please enter your delivery commit title: (leaving blank will use default)" => 'title',
|
484
|
+
"Please enter your delivery commit message: (leaving blank will use default)" => 'message'
|
485
|
+
}
|
486
|
+
return_value = values[question] || values[terminal]
|
487
|
+
question = ""
|
488
|
+
return_value
|
489
|
+
end
|
490
|
+
end
|
491
|
+
|
492
|
+
it "doesn't cleans up feature branch" do
|
493
|
+
expect(subject).to be_falsy
|
494
|
+
end
|
495
|
+
end
|
496
|
+
|
497
|
+
context "does cleanup feature branch" do
|
498
|
+
before do
|
499
|
+
stub_command_line_inputs({
|
500
|
+
"Please enter your GitHub username: " => user,
|
501
|
+
"Please enter your GitHub password (we do NOT store this): " => password,
|
502
|
+
"Please enter your Enterprise site URL (e.g. https://github.company.com):" => enterprise_site,
|
503
|
+
"Please enter your Enterprise API endpoint (e.g. https://github.company.com/api/v3):" => enterprise_api,
|
504
|
+
"Would you like to push this branch to your remote repo and cleanup your feature branch? " => 'yes',
|
505
|
+
"This is the current status of your Pull Request. Are you sure you want to deliver? " => 'n',
|
506
|
+
"Please enter your delivery commit title: (leaving blank will use default)" => 'title',
|
507
|
+
"Please enter your delivery commit message: (leaving blank will use default)" => 'message'
|
508
|
+
})
|
509
|
+
end
|
510
|
+
|
511
|
+
it "cleans up feature branch" do
|
512
|
+
expect(subject).to be_truthy
|
513
|
+
end
|
514
|
+
end
|
515
|
+
end
|
516
|
+
|
517
|
+
context :deliver? do
|
518
|
+
subject { GitReflow::GitServer::GitHub::PullRequest.new(pull_request).deliver? }
|
519
|
+
|
520
|
+
before do
|
521
|
+
allow(GitReflow::Config).to receive(:get).with("reflow.always-deliver").and_return("false")
|
522
|
+
allow_any_instance_of(GitReflow::GitServer::GitHub::PullRequest).to receive(:build).and_return(Struct.new(:state, :description, :url).new)
|
523
|
+
FakeGitHub.new(
|
524
|
+
repo_owner: 'reenhanced',
|
525
|
+
repo_name: 'repo',
|
526
|
+
pull_request: {
|
527
|
+
number: pull_request.number,
|
528
|
+
owner: pull_request.head.user.login,
|
529
|
+
comments: [{author: 'tito', body: 'lgtm'}, {author: 'ringo', body: ':+1:'}]
|
530
|
+
})
|
531
|
+
end
|
532
|
+
|
533
|
+
context "doesn't deliver feature branch" do
|
534
|
+
before do
|
535
|
+
allow_any_instance_of(HighLine).to receive(:ask) do |terminal, question|
|
536
|
+
values = {
|
537
|
+
"Please enter your GitHub username: " => user,
|
538
|
+
"Please enter your GitHub password (we do NOT store this): " => password,
|
539
|
+
"Please enter your Enterprise site URL (e.g. https://github.company.com):" => enterprise_site,
|
540
|
+
"Please enter your Enterprise API endpoint (e.g. https://github.company.com/api/v3):" => enterprise_api,
|
541
|
+
"Would you like to push this branch to your remote repo and cleanup your feature branch? " => 'no',
|
542
|
+
"Would you like to open it in your browser?" => 'n',
|
543
|
+
"This is the current status of your Pull Request. Are you sure you want to deliver? " => 'n',
|
544
|
+
"Please enter your delivery commit title: (leaving blank will use default)" => 'title',
|
545
|
+
"Please enter your delivery commit message: (leaving blank will use default)" => 'message'
|
546
|
+
}
|
547
|
+
return_value = values[question] || values[terminal]
|
548
|
+
question = ""
|
549
|
+
return_value
|
550
|
+
end
|
551
|
+
end
|
552
|
+
|
553
|
+
it "doesn't deliver feature branch" do
|
554
|
+
expect(subject).to be_falsy
|
555
|
+
end
|
556
|
+
end
|
557
|
+
|
558
|
+
context "does deliver feature branch" do
|
559
|
+
before do
|
560
|
+
allow_any_instance_of(HighLine).to receive(:ask) do |terminal, question|
|
561
|
+
values = {
|
562
|
+
"Please enter your GitHub username: " => user,
|
563
|
+
"Please enter your GitHub password (we do NOT store this): " => password,
|
564
|
+
"Please enter your Enterprise site URL (e.g. https://github.company.com):" => enterprise_site,
|
565
|
+
"Please enter your Enterprise API endpoint (e.g. https://github.company.com/api/v3):" => enterprise_api,
|
566
|
+
"Would you like to push this branch to your remote repo and cleanup your feature branch? " => 'no',
|
567
|
+
"Would you like to open it in your browser?" => 'n',
|
568
|
+
"This is the current status of your Pull Request. Are you sure you want to deliver? " => 'y',
|
569
|
+
"Please enter your delivery commit title: (leaving blank will use default)" => 'title',
|
570
|
+
"Please enter your delivery commit message: (leaving blank will use default)" => 'message'
|
571
|
+
}
|
572
|
+
return_value = values[question] || values[terminal]
|
573
|
+
question = ""
|
574
|
+
return_value
|
575
|
+
end
|
576
|
+
end
|
577
|
+
|
578
|
+
it "does deliver feature branch" do
|
579
|
+
expect(subject).to be_truthy
|
580
|
+
end
|
581
|
+
end
|
582
|
+
end
|
392
583
|
end
|
@@ -8,10 +8,8 @@ module CommandLineHelpers
|
|
8
8
|
stub_run_for GitReflow
|
9
9
|
stub_run_for GitReflow::Sandbox
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
output = ''
|
14
|
-
end
|
11
|
+
stub_output_for(GitReflow)
|
12
|
+
stub_output_for(GitReflow::Sandbox)
|
15
13
|
|
16
14
|
allow_any_instance_of(GitReflow::GitServer::PullRequest).to receive(:printf) do |format, *output|
|
17
15
|
$output << Array(output).join(" ")
|
@@ -19,15 +17,22 @@ module CommandLineHelpers
|
|
19
17
|
end.and_return("")
|
20
18
|
end
|
21
19
|
|
20
|
+
def stub_output_for(object_to_stub, method_to_stub = :puts)
|
21
|
+
allow_any_instance_of(object_to_stub).to receive(method_to_stub) do |output|
|
22
|
+
$output << output
|
23
|
+
output = ''
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
22
27
|
def stub_run_for(module_to_stub)
|
23
|
-
module_to_stub.
|
28
|
+
allow(module_to_stub).to receive(:run) do |command, options|
|
24
29
|
options ||= {}
|
25
30
|
$commands_ran << Hashie::Mash.new(command: command, options: options)
|
26
31
|
ret_value = $stubbed_commands[command] || ""
|
27
32
|
command = "" # we need this due to a bug in rspec that will keep this assignment on subsequent runs of the stub
|
28
33
|
ret_value
|
29
34
|
end
|
30
|
-
module_to_stub.
|
35
|
+
allow(module_to_stub).to receive(:say) do |output, type|
|
31
36
|
$says << {message: output, type: type}
|
32
37
|
end
|
33
38
|
end
|
@@ -41,11 +46,11 @@ module CommandLineHelpers
|
|
41
46
|
|
42
47
|
def stub_command(command, return_value)
|
43
48
|
$stubbed_commands[command] = return_value
|
44
|
-
GitReflow::Sandbox.
|
49
|
+
allow(GitReflow::Sandbox).to receive(:run).with(command).and_return(return_value)
|
45
50
|
end
|
46
51
|
|
47
52
|
def stub_command_line_inputs(inputs)
|
48
|
-
HighLine.
|
53
|
+
allow_any_instance_of(HighLine).to receive(:ask) do |terminal, question|
|
49
54
|
return_value = inputs[question]
|
50
55
|
question = ""
|
51
56
|
return_value
|
@@ -93,7 +98,7 @@ RSpec::Matchers.define :have_run_commands_in_order do |commands|
|
|
93
98
|
next unless command_start_index
|
94
99
|
if command_count >= 1
|
95
100
|
current_command = commands[command_count - 1]
|
96
|
-
current_command.
|
101
|
+
expect(current_command).to eq(command_ran.command)
|
97
102
|
command_count -= 1
|
98
103
|
end
|
99
104
|
end
|
@@ -16,7 +16,7 @@ module GithubHelpers
|
|
16
16
|
branch = options[:branch] || 'new-feature'
|
17
17
|
pull = options[:pull]
|
18
18
|
|
19
|
-
HighLine.
|
19
|
+
allow_any_instance_of(HighLine).to receive(:ask) do |terminal, question|
|
20
20
|
values = {
|
21
21
|
"Please enter your GitHub username: " => user,
|
22
22
|
"Please enter your GitHub password (we do NOT store this): " => password,
|
@@ -37,27 +37,27 @@ module GithubHelpers
|
|
37
37
|
end
|
38
38
|
|
39
39
|
stub_request(:get, "#{api_endpoint}/authorizations?").to_return(:body => [oauth_token_hash].to_json, status: 200, headers: {})
|
40
|
-
Github.
|
41
|
-
GitReflow.
|
42
|
-
GitReflow.
|
43
|
-
GitReflow.
|
44
|
-
GitReflow.
|
45
|
-
GitReflow.
|
46
|
-
GitReflow.
|
47
|
-
GitReflow.
|
40
|
+
allow(Github::Client).to receive(:new).and_return(github)
|
41
|
+
allow(GitReflow).to receive(:push_current_branch).and_return(true)
|
42
|
+
allow(GitReflow).to receive(:github).and_return(github)
|
43
|
+
allow(GitReflow).to receive(:current_branch).and_return(branch)
|
44
|
+
allow(GitReflow).to receive(:remote_repo_name).and_return(repo)
|
45
|
+
allow(GitReflow).to receive(:remote_user).and_return(user)
|
46
|
+
allow(GitReflow).to receive(:fetch_destination).and_return(true)
|
47
|
+
allow(GitReflow).to receive(:update_destination).and_return(true)
|
48
48
|
|
49
|
-
GitReflow::GitServer::GitHub.
|
49
|
+
allow_any_instance_of(GitReflow::GitServer::GitHub).to receive(:run).with('hostname', loud: false).and_return(hostname)
|
50
50
|
github_server = GitReflow::GitServer::GitHub.new
|
51
|
-
github_server.class.
|
52
|
-
github_server.class.
|
53
|
-
github_server.class.
|
54
|
-
github_server.class.
|
55
|
-
github_server.class.
|
56
|
-
github_server.class.
|
57
|
-
github_server.class.
|
58
|
-
github_server.class.
|
51
|
+
allow(github_server.class).to receive(:user).and_return(user)
|
52
|
+
allow(github_server.class).to receive(:oauth_token).and_return(oauth_token_hash.token)
|
53
|
+
allow(github_server.class).to receive(:site_url).and_return(site_url)
|
54
|
+
allow(github_server.class).to receive(:api_endpoint).and_return(api_endpoint)
|
55
|
+
allow(github_server.class).to receive(:remote_user).and_return(user)
|
56
|
+
allow(github_server.class).to receive(:remote_repo).and_return(repo)
|
57
|
+
allow(github_server.class).to receive(:oauth_token).and_return(oauth_token_hash.token)
|
58
|
+
allow(github_server.class).to receive(:get_committed_time).and_return(Time.now)
|
59
59
|
|
60
|
-
GitReflow.
|
60
|
+
allow(GitReflow).to receive(:git_server).and_return(github_server)
|
61
61
|
|
62
62
|
# Stubbing statuses for a given commit
|
63
63
|
#stub_request(:get, %r{#{GitReflow.git_server.class.api_endpoint}/repos/#{user}/commits/\w+}).
|
@@ -79,9 +79,9 @@ module GithubHelpers
|
|
79
79
|
to_return(:body => Fixture.new('pull_requests/pull_requests.json').to_s, :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
|
80
80
|
# Stubbing pull request comments
|
81
81
|
stub_get("/repos/#{user}/#{repo}/pulls/#{pull.number}/comments?").with(:query => {'access_token' => 'a1b2c3d4e5f6g7h8i9j0'}).
|
82
|
-
to_return(:body => Fixture.new('pull_requests/comments.json.erb', repo_owner: user, repo_name: repo, comments: [{author: user}], pull_request_number: pull.number).to_json.to_s, :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
|
82
|
+
to_return(:body => Fixture.new('pull_requests/comments.json.erb', repo_owner: user, repo_name: repo, comments: [{author: user}], pull_request_number: pull.number).to_json.to_s, :status => 201, :headers => {'Accept' => 'application/vnd.github.v3+json,application/vnd.github.beta+json;q=0.5,application/json;q=0.1', :content_type => "application/json; charset=utf-8"})
|
83
83
|
stub_get("/repos/#{user}/pulls/#{pull.number}/comments?").with(:query => {'access_token' => 'a1b2c3d4e5f6g7h8i9j0'}).
|
84
|
-
to_return(:body => Fixture.new('pull_requests/comments.json.erb', repo_owner: user, repo_name: repo, comments: [{author: user}], pull_request_number: pull.number).to_s, :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
|
84
|
+
to_return(:body => Fixture.new('pull_requests/comments.json.erb', repo_owner: user, repo_name: repo, comments: [{author: user}], pull_request_number: pull.number).to_s, :status => 201, :headers => {'Accept' => 'application/vnd.github.v3+json,application/vnd.github.beta+json;q=0.5,application/json;q=0.1', :content_type => "application/json; charset=utf-8"})
|
85
85
|
# Stubbing issue comments
|
86
86
|
stub_get("/repos/#{user}/issues/#{pull.number}/comments?").with(:query => {'access_token' => 'a1b2c3d4e5f6g7h8i9j0'}).
|
87
87
|
to_return(:body => Fixture.new('issues/comments.json.erb', repo_owner: user, repo_name: repo, comments: [{author: user}], pull_request_number: pull.number).to_s, :status => 201, :headers => {:content_type => "application/json; charset=utf-8"})
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module RspecStubHelpers
|
2
2
|
def stub_with_fallback(obj, method)
|
3
3
|
original_method = obj.method(method)
|
4
|
-
obj.
|
5
|
-
return obj.
|
4
|
+
allow(obj).to receive(method).with(anything()) { |*args| original_method.call(*args) }
|
5
|
+
return allow(obj).to receive(method)
|
6
6
|
end
|
7
7
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_reflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valentino Stoll
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-05-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: appraisal
|
@@ -18,28 +18,28 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.0
|
21
|
+
version: 2.1.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 1.0
|
28
|
+
version: 2.1.0
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: bundler
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: '1.
|
35
|
+
version: '1.12'
|
36
36
|
type: :development
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '1.
|
42
|
+
version: '1.12'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: chronic
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,14 +74,14 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - "~>"
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: '
|
77
|
+
version: '11.0'
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
82
|
- - "~>"
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: '
|
84
|
+
version: '11.0'
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: rdoc
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,14 +102,14 @@ dependencies:
|
|
102
102
|
requirements:
|
103
103
|
- - "~>"
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version:
|
105
|
+
version: 3.4.0
|
106
106
|
type: :development
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
110
|
- - "~>"
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version:
|
112
|
+
version: 3.4.0
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: webmock
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,14 +130,14 @@ dependencies:
|
|
130
130
|
requirements:
|
131
131
|
- - '='
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
133
|
+
version: 1.3.0
|
134
134
|
type: :development
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
137
|
requirements:
|
138
138
|
- - '='
|
139
139
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
140
|
+
version: 1.3.0
|
141
141
|
- !ruby/object:Gem::Dependency
|
142
142
|
name: colorize
|
143
143
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,14 +158,14 @@ dependencies:
|
|
158
158
|
requirements:
|
159
159
|
- - '='
|
160
160
|
- !ruby/object:Gem::Version
|
161
|
-
version: 2.
|
161
|
+
version: 2.14.0
|
162
162
|
type: :runtime
|
163
163
|
prerelease: false
|
164
164
|
version_requirements: !ruby/object:Gem::Requirement
|
165
165
|
requirements:
|
166
166
|
- - '='
|
167
167
|
- !ruby/object:Gem::Version
|
168
|
-
version: 2.
|
168
|
+
version: 2.14.0
|
169
169
|
- !ruby/object:Gem::Dependency
|
170
170
|
name: highline
|
171
171
|
requirement: !ruby/object:Gem::Requirement
|
@@ -200,14 +200,14 @@ dependencies:
|
|
200
200
|
requirements:
|
201
201
|
- - '='
|
202
202
|
- !ruby/object:Gem::Version
|
203
|
-
version: 0.
|
203
|
+
version: 0.14.0
|
204
204
|
type: :runtime
|
205
205
|
prerelease: false
|
206
206
|
version_requirements: !ruby/object:Gem::Requirement
|
207
207
|
requirements:
|
208
208
|
- - '='
|
209
209
|
- !ruby/object:Gem::Version
|
210
|
-
version: 0.
|
210
|
+
version: 0.14.0
|
211
211
|
- !ruby/object:Gem::Dependency
|
212
212
|
name: reenhanced_bitbucket_api
|
213
213
|
requirement: !ruby/object:Gem::Requirement
|
@@ -247,6 +247,7 @@ files:
|
|
247
247
|
- lib/git_reflow.rb
|
248
248
|
- lib/git_reflow/base.rb
|
249
249
|
- lib/git_reflow/commands/deliver.rb
|
250
|
+
- lib/git_reflow/commands/refresh.rb
|
250
251
|
- lib/git_reflow/commands/review.rb
|
251
252
|
- lib/git_reflow/commands/setup.rb
|
252
253
|
- lib/git_reflow/commands/stage.rb
|
@@ -261,6 +262,7 @@ files:
|
|
261
262
|
- lib/git_reflow/git_server/git_hub.rb
|
262
263
|
- lib/git_reflow/git_server/git_hub/pull_request.rb
|
263
264
|
- lib/git_reflow/git_server/pull_request.rb
|
265
|
+
- lib/git_reflow/merge_error.rb
|
264
266
|
- lib/git_reflow/os_detector.rb
|
265
267
|
- lib/git_reflow/sandbox.rb
|
266
268
|
- lib/git_reflow/version.rb
|