git-process 1.0.11 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +37 -9
- data/Gemfile +2 -2
- data/Gemfile.lock +17 -17
- data/README.md +14 -7
- data/bin/git-new-fb +10 -2
- data/bin/git-pull-request +30 -6
- data/bin/git-sync +5 -2
- data/bin/git-to-master +62 -11
- data/git-process.gemspec +15 -15
- data/lib/git-process/abstract_error_builder.rb +0 -3
- data/lib/git-process/changed_file_helper.rb +30 -24
- data/lib/git-process/git_abstract_merge_error_builder.rb +31 -11
- data/lib/git-process/git_branch.rb +5 -0
- data/lib/git-process/git_config.rb +153 -0
- data/lib/git-process/git_lib.rb +212 -164
- data/lib/git-process/git_logger.rb +84 -0
- data/lib/git-process/git_merge_error.rb +3 -14
- data/lib/git-process/git_process.rb +44 -73
- data/lib/git-process/git_process_options.rb +6 -6
- data/lib/git-process/git_rebase_error.rb +4 -13
- data/lib/git-process/git_remote.rb +254 -0
- data/lib/git-process/github_configuration.rb +298 -0
- data/lib/git-process/github_pull_request.rb +65 -27
- data/lib/git-process/new_fb.rb +14 -4
- data/lib/git-process/parked_changes_error.rb +1 -1
- data/lib/git-process/pull_request.rb +100 -13
- data/lib/git-process/pull_request_error.rb +25 -0
- data/lib/git-process/rebase_to_master.rb +47 -27
- data/lib/git-process/sync.rb +48 -33
- data/lib/git-process/uncommitted_changes_error.rb +1 -1
- data/lib/git-process/version.rb +2 -2
- data/spec/GitRepoHelper.rb +48 -25
- data/spec/changed_file_helper_spec.rb +39 -58
- data/spec/git_abstract_merge_error_builder_spec.rb +42 -33
- data/spec/git_branch_spec.rb +30 -30
- data/spec/git_config_spec.rb +45 -0
- data/spec/git_lib_spec.rb +103 -122
- data/spec/git_logger_spec.rb +66 -0
- data/spec/git_process_spec.rb +81 -81
- data/spec/git_remote_spec.rb +188 -0
- data/spec/git_status_spec.rb +36 -36
- data/spec/github_configuration_spec.rb +152 -0
- data/spec/github_pull_request_spec.rb +39 -35
- data/spec/github_test_helper.rb +49 -0
- data/spec/new_fb_spec.rb +65 -24
- data/spec/pull_request_helper.rb +94 -0
- data/spec/pull_request_spec.rb +128 -0
- data/spec/rebase_to_master_spec.rb +241 -145
- data/spec/spec_helper.rb +20 -0
- data/spec/sync_spec.rb +115 -109
- metadata +34 -20
- data/lib/git-process/github_client.rb +0 -83
- data/lib/git-process/github_service.rb +0 -174
- data/spec/github_service_spec.rb +0 -211
@@ -1,22 +1,12 @@
|
|
1
1
|
require 'git-process/pull_request'
|
2
2
|
require 'GitRepoHelper'
|
3
|
-
require '
|
3
|
+
require 'github_test_helper'
|
4
4
|
require 'json'
|
5
5
|
require 'octokit'
|
6
6
|
require 'tempfile'
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
include GitRepoHelper
|
11
|
-
|
12
|
-
|
13
|
-
def lib
|
14
|
-
unless @lib
|
15
|
-
@lib = double('lib')
|
16
|
-
@lib.stub(:logger).and_return(logger)
|
17
|
-
end
|
18
|
-
@lib
|
19
|
-
end
|
8
|
+
describe GitHub::PullRequest, :git_repo_helper do
|
9
|
+
include GitHubTestHelper
|
20
10
|
|
21
11
|
|
22
12
|
def test_token
|
@@ -25,34 +15,32 @@ describe GitHub::PullRequest do
|
|
25
15
|
|
26
16
|
|
27
17
|
def pull_request
|
28
|
-
@pr ||= GitHub::PullRequest.new(
|
18
|
+
@pr ||= GitHub::PullRequest.new(gitlib, 'test_remote', 'test_repo', :user => 'test_user')
|
29
19
|
end
|
30
20
|
|
31
21
|
|
32
22
|
before(:each) do
|
33
|
-
|
34
|
-
|
23
|
+
gitlib.config['gitProcess.github.authToken'] = test_token
|
24
|
+
gitlib.remote.add('test_remote', 'git@github.com:test_repo.git')
|
35
25
|
end
|
36
26
|
|
37
27
|
|
38
|
-
describe
|
28
|
+
describe '#create' do
|
39
29
|
|
40
|
-
it
|
41
|
-
|
42
|
-
to_return(:status => 200, :body => JSON({:number => 1, :state => 'open'}))
|
30
|
+
it 'should return a pull request for a good request' do
|
31
|
+
stub_post('https://api.github.com/repos/test_repo/pulls', :body => {:number => 1, :state => 'open'})
|
43
32
|
|
44
33
|
pull_request.create('test_base', 'test_head', 'test title', 'test body')[:state].should == 'open'
|
45
34
|
end
|
46
35
|
|
47
36
|
|
48
|
-
it
|
37
|
+
it 'should handle asking for a duplicate pull request' do
|
49
38
|
# trying to create the request should return "HTTP 422: Unprocessable Entity" because it already exists
|
50
|
-
|
51
|
-
to_return(:status => 422)
|
39
|
+
stub_post("https://api.github.com/repos/test_repo/pulls", :status => 422)
|
52
40
|
|
53
41
|
# listing all existing pull requests should contain the current branch
|
54
|
-
|
55
|
-
|
42
|
+
stub_get('https://api.github.com/repos/test_repo/pulls?state=open', :status => 200,
|
43
|
+
:body => [{:html_url => 'test_url', :head => {:ref => 'test_head'}, :base => {:ref => 'test_base'}}])
|
56
44
|
|
57
45
|
pull_request.create('test_base', 'test_head', 'test title', 'test body')[:html_url].should == 'test_url'
|
58
46
|
end
|
@@ -60,31 +48,47 @@ describe GitHub::PullRequest do
|
|
60
48
|
end
|
61
49
|
|
62
50
|
|
63
|
-
describe "
|
51
|
+
describe "get" do
|
52
|
+
|
53
|
+
it "should return a pull request for a good request" do
|
54
|
+
stub_get('https://api.github.com/repos/test_repo/pulls/1', :body => {:number => 1, :state => 'open'})
|
55
|
+
|
56
|
+
pull_request.pull_request(1)[:state].should == 'open'
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
describe '#close' do
|
64
63
|
|
65
64
|
it "should close a good current pull request" do
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
to_return(:status => 200, :body => JSON({:number => 1, :state => 'closed', :html_url => 'test_url', :head => {:ref => 'test_head'}, :base => {:ref => 'test_base'}}))
|
65
|
+
stub_get('https://api.github.com/repos/test_repo/pulls?state=open', :body => [{:number => 1, :state => 'open', :html_url => 'test_url', :head => {:ref => 'test_head'}, :base => {:ref => 'test_base'}}])
|
66
|
+
stub_patch('https://api.github.com/repos/test_repo/pulls/1', :send => JSON({:state => 'closed'}),
|
67
|
+
:body => {:number => 1, :state => 'closed', :html_url => 'test_url', :head => {:ref => 'test_head'}, :base => {:ref => 'test_base'}})
|
70
68
|
|
71
69
|
pull_request.close('test_base', 'test_head')[:state].should == 'closed'
|
72
70
|
end
|
73
71
|
|
74
72
|
|
75
73
|
it "should close a good current pull request using the pull request number" do
|
76
|
-
|
77
|
-
|
74
|
+
stub_patch('https://api.github.com/repos/test_repo/pulls/1', :send => JSON({:state => 'closed'}),
|
75
|
+
:body => {:number => 1, :state => 'closed', :html_url => 'test_url',
|
76
|
+
:head => {:ref => 'test_head'}, :base => {:ref => 'test_base'}})
|
78
77
|
|
79
78
|
pull_request.close(1)[:state].should == 'closed'
|
80
79
|
end
|
81
80
|
|
82
81
|
|
83
82
|
it "should complain about a missing pull request" do
|
84
|
-
|
85
|
-
|
83
|
+
stub_get('https://api.github.com/repos/test_repo/pulls?state=open', :body => [{:number => 1, :state => 'open', :html_url => 'test_url', :head => {:ref => 'test_head'}, :base => {:ref => 'test_base'}}])
|
84
|
+
|
85
|
+
expect { pull_request.close('test_base', 'missing_head') }.to raise_error GitHub::PullRequest::NotFoundError
|
86
|
+
end
|
87
|
+
|
86
88
|
|
87
|
-
|
89
|
+
it "should complain about wrong number of arguments" do
|
90
|
+
expect { pull_request.close() }.to raise_error ::ArgumentError
|
91
|
+
expect { pull_request.close('1', '2', '3') }.to raise_error ::ArgumentError
|
88
92
|
end
|
89
93
|
|
90
94
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'FileHelpers'
|
2
|
+
require 'git-process/git_process'
|
3
|
+
require 'webmock/rspec'
|
4
|
+
|
5
|
+
module GitHubTestHelper
|
6
|
+
|
7
|
+
|
8
|
+
def stub_get(url, opts = {})
|
9
|
+
stub = stub_request(:get, url)
|
10
|
+
|
11
|
+
if opts[:token]
|
12
|
+
stub.with(:Authorization => "token #{opts[:token]}")
|
13
|
+
end
|
14
|
+
|
15
|
+
stub.to_return(:status => opts[:status] ? opts[:status] : 200, :body => opts[:body] ? opts[:body] : '')
|
16
|
+
stub
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def stub_post(url, opts = {})
|
21
|
+
stub = stub_request(:post, url)
|
22
|
+
|
23
|
+
if opts[:token]
|
24
|
+
stub.with(:Authorization => "token #{opts[:token]}")
|
25
|
+
end
|
26
|
+
|
27
|
+
stub.to_return(:status => opts[:status] ? opts[:status] : 200, :body => opts[:body] ? opts[:body] : '')
|
28
|
+
|
29
|
+
stub
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def stub_patch(url, opts = {})
|
34
|
+
stub = stub_request(:patch, url)
|
35
|
+
|
36
|
+
if opts[:token]
|
37
|
+
stub.with(:Authorization => "token #{opts[:token]}")
|
38
|
+
end
|
39
|
+
|
40
|
+
if opts[:send]
|
41
|
+
stub.with(:body => opts[:send])
|
42
|
+
end
|
43
|
+
|
44
|
+
stub.to_return(:status => opts[:status] ? opts[:status] : 200, :body => opts[:body] ? opts[:body] : '')
|
45
|
+
|
46
|
+
stub
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/spec/new_fb_spec.rb
CHANGED
@@ -1,58 +1,99 @@
|
|
1
1
|
require 'git-process/new_fb'
|
2
2
|
require 'GitRepoHelper'
|
3
|
+
include GitProc
|
3
4
|
|
4
|
-
|
5
|
+
|
6
|
+
describe NewFeatureBranch do
|
5
7
|
include GitRepoHelper
|
6
8
|
|
7
9
|
before(:each) do
|
8
|
-
create_files(
|
9
|
-
|
10
|
+
create_files(%w(.gitignore))
|
11
|
+
gitlib.commit('initial')
|
10
12
|
end
|
11
13
|
|
12
14
|
|
13
15
|
after(:each) do
|
14
|
-
rm_rf(
|
16
|
+
rm_rf(gitlib.workdir)
|
15
17
|
end
|
16
18
|
|
17
19
|
|
18
|
-
def create_process(dir, opts)
|
20
|
+
def create_process(dir, opts = {})
|
19
21
|
opts[:branch_name] = 'test_branch'
|
20
|
-
|
22
|
+
NewFeatureBranch.new(dir, opts)
|
21
23
|
end
|
22
24
|
|
23
25
|
|
24
|
-
describe
|
26
|
+
describe '#new_feature_branch' do
|
25
27
|
|
26
28
|
def log_level
|
27
29
|
Logger::ERROR
|
28
30
|
end
|
29
31
|
|
30
32
|
|
31
|
-
it
|
32
|
-
|
33
|
+
it 'should create the named branch against origin/master' do
|
34
|
+
clone_repo do |gl|
|
35
|
+
gp = create_process(gl)
|
36
|
+
gl.checkout('other_branch', :new_branch => 'master')
|
37
|
+
change_file_and_commit('a', '', gl)
|
38
|
+
change_file_and_commit('b', '', gl)
|
33
39
|
new_branch = gp.runner
|
34
40
|
|
35
41
|
new_branch.name.should == 'test_branch'
|
36
|
-
new_branch.sha.should ==
|
42
|
+
new_branch.sha.should == gl.branches['origin/master'].sha
|
37
43
|
end
|
38
44
|
end
|
39
45
|
|
40
46
|
|
41
47
|
it "should bring committed changes on _parking_ over to the new branch" do
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
48
|
+
clone_repo do |gl|
|
49
|
+
gl.checkout('_parking_', :new_branch => 'master')
|
50
|
+
change_file_and_commit('a', '', gl)
|
51
|
+
change_file_and_commit('b', '', gl)
|
46
52
|
|
47
|
-
|
53
|
+
gp = create_process(gl)
|
54
|
+
new_branch = gp.runner
|
48
55
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
56
|
+
new_branch.name.should == 'test_branch'
|
57
|
+
Dir.chdir(gl.workdir) do |_|
|
58
|
+
File.exists?('a').should be_true
|
59
|
+
File.exists?('b').should be_true
|
60
|
+
end
|
61
|
+
|
62
|
+
gl.config["branch.test_branch.remote"].should == 'origin'
|
63
|
+
gl.config["branch.test_branch.merge"].should == 'refs/heads/master'
|
64
|
+
|
65
|
+
gl.fetch
|
66
|
+
gl.branches.parking.should be_nil
|
67
|
+
new_branch.sha.should_not == gl.branches['origin/master'].sha
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
it "should move new branch over to the integration branch" do
|
74
|
+
clone_repo do |gl|
|
75
|
+
gl.checkout('_parking_', :new_branch => 'master')
|
76
|
+
change_file_and_commit('a', '', gitlib)
|
77
|
+
change_file_and_commit('b', '', gitlib)
|
78
|
+
|
79
|
+
gl.fetch
|
80
|
+
gp = create_process(gl)
|
81
|
+
new_branch = gp.runner
|
82
|
+
|
83
|
+
new_branch.name.should == 'test_branch'
|
84
|
+
Dir.chdir(gitlib.workdir) do |_|
|
85
|
+
File.exists?('a').should be_true
|
86
|
+
File.exists?('b').should be_true
|
87
|
+
end
|
88
|
+
|
89
|
+
gl.config["branch.test_branch.remote"].should == 'origin'
|
90
|
+
gl.config["branch.test_branch.merge"].should == 'refs/heads/master'
|
91
|
+
|
92
|
+
gl.fetch
|
93
|
+
gl.branches.parking.should be_nil
|
94
|
+
new_branch.sha.should == gl.branches['origin/master'].sha
|
53
95
|
end
|
54
96
|
|
55
|
-
gitprocess.branches.parking.should be_nil
|
56
97
|
end
|
57
98
|
|
58
99
|
|
@@ -66,8 +107,8 @@ describe GitProc::NewFeatureBranch do
|
|
66
107
|
|
67
108
|
|
68
109
|
it "should bring new/uncommitted changes on _parking_ over to the new branch" do
|
69
|
-
|
70
|
-
|
110
|
+
gitlib.branch('origin/master', :base_branch => 'master')
|
111
|
+
gitlib.checkout('_parking_', :new_branch => 'master')
|
71
112
|
change_file_and_commit('a', '')
|
72
113
|
change_file_and_add('b', '')
|
73
114
|
change_file('c', '')
|
@@ -75,13 +116,13 @@ describe GitProc::NewFeatureBranch do
|
|
75
116
|
new_branch = gitprocess.runner
|
76
117
|
|
77
118
|
new_branch.name.should == 'test_branch'
|
78
|
-
Dir.chdir(
|
119
|
+
Dir.chdir(gitlib.workdir) do |_|
|
79
120
|
File.exists?('a').should be_true
|
80
121
|
File.exists?('b').should be_true
|
81
122
|
File.exists?('c').should be_true
|
82
123
|
end
|
83
124
|
|
84
|
-
|
125
|
+
gitlib.branches.parking.should be_nil
|
85
126
|
end
|
86
127
|
|
87
128
|
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module PullRequestHelper
|
2
|
+
|
3
|
+
def create_pull_request(opts = {})
|
4
|
+
v = {
|
5
|
+
:head_remote => 'testrepo',
|
6
|
+
:head_repo => 'test_repo',
|
7
|
+
:base_repo => 'test_repo',
|
8
|
+
:head_branch => 'test_branch',
|
9
|
+
:base_branch => 'source_branch',
|
10
|
+
:api_url => 'https://api.github.com',
|
11
|
+
:pr_number => '32',
|
12
|
+
:state => 'open',
|
13
|
+
}
|
14
|
+
v.merge! opts
|
15
|
+
v[:ssh_head_url] = "git@github.com:#{opts[:head_repo] || v[:head_repo]}.git" unless opts.has_key?(:ssh_head_url)
|
16
|
+
v[:ssh_base_url] = "git@github.com:#{opts[:base_repo] || v[:base_repo]}.git" unless opts.has_key?(:ssh_base_url)
|
17
|
+
PullRequestHelper::_basic_pull_request_data(v)
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def self._basic_pull_request_data(opts = {})
|
22
|
+
{
|
23
|
+
:number => opts[:pr_number],
|
24
|
+
:state => opts[:state],
|
25
|
+
:head => {
|
26
|
+
:remote => opts[:head_repo], # pseudo-property for testing
|
27
|
+
:ref => opts[:head_branch],
|
28
|
+
:repo => {
|
29
|
+
:name => opts[:head_repo],
|
30
|
+
:ssh_url => opts[:ssh_head_url],
|
31
|
+
}
|
32
|
+
},
|
33
|
+
:base => {
|
34
|
+
:remote => opts[:base_repo], # pseudo-property for testing
|
35
|
+
:ref => opts[:base_branch],
|
36
|
+
:repo => {
|
37
|
+
:name => opts[:base_repo],
|
38
|
+
:ssh_url => opts[:ssh_base_url],
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
# @abstract the Hash/JSON of the pull request structure to use
|
46
|
+
# @return [Hash]
|
47
|
+
def pull_request
|
48
|
+
raise NotImplementedError
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def api_url(remote_name, glib = gitlib)
|
53
|
+
GitHubService::Configuration.new(glib.config, :remote_name => remote_name).base_github_api_url_for_remote
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
def stub_get_pull_request(pr, glib = gitlib)
|
58
|
+
api_url = api_url(pr[:head][:remote], glib)
|
59
|
+
stub_get("#{api_url}/repos/#{pr[:head][:repo][:name]}/pulls/#{pr[:number]}", :body => pr)
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def stub_fetch(which_remote, glib = gitlib)
|
64
|
+
rem = pull_request[which_remote][:remote]
|
65
|
+
glib.stub(:fetch).with(rem)
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
#
|
70
|
+
# Adds a remote to git's configuration based on {#pull_request}
|
71
|
+
#
|
72
|
+
# @param [:head, :base] which_remote
|
73
|
+
#
|
74
|
+
def add_remote(which_remote, glib = gitlib)
|
75
|
+
glib.remote.add(pull_request[which_remote][:remote], pull_request[which_remote][:repo][:ssh_url])
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
# Verifies the branch is checked out from the HEAD branch of the pull
|
80
|
+
# request and created by the same name
|
81
|
+
def expect_checkout_pr_head(glib = gitlib)
|
82
|
+
pr = pull_request
|
83
|
+
glib.should_receive(:checkout).with(pr[:head][:ref], :new_branch => "#{pr[:head][:remote]}/#{pr[:head][:ref]}")
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
# Verifies the tracking for the new branch is set to the BASE branch
|
88
|
+
# of the pull request
|
89
|
+
def expect_upstream_set(glib = gitlib)
|
90
|
+
pr = pull_request
|
91
|
+
glib.should_receive(:branch).with(pr[:head][:ref], :upstream => "#{pr[:base][:remote]}/#{pr[:base][:ref]}")
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'git-process/pull_request'
|
2
|
+
#require 'git-process/github_configuration'
|
3
|
+
require 'github_test_helper'
|
4
|
+
require 'pull_request_helper'
|
5
|
+
require 'GitRepoHelper'
|
6
|
+
|
7
|
+
|
8
|
+
describe GitProc::PullRequest do
|
9
|
+
include GitRepoHelper
|
10
|
+
include GitHubTestHelper
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
create_files(%w(.gitignore))
|
14
|
+
gitlib.commit('initial')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
after(:each) do
|
19
|
+
rm_rf(gitlib.workdir)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def log_level
|
24
|
+
Logger::ERROR
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
describe 'with no parameters' do
|
29
|
+
def create_process(dir, opts)
|
30
|
+
GitProc::PullRequest.new(dir, opts)
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
it 'should push the branch and create a default pull request' do
|
35
|
+
pr_client = double('pr_client')
|
36
|
+
|
37
|
+
gitlib.config['gitProcess.integrationBranch'] = 'develop'
|
38
|
+
gitlib.remote.add('origin', 'git@github.com:jdigger/git-process.git')
|
39
|
+
|
40
|
+
GitProc::PullRequest.stub(:create_pull_request_client).and_return(pr_client)
|
41
|
+
#PullRequest.stub(:create_pull_request_client).with(anything, 'origin', 'jdigger/git-process').and_return(pr_client)
|
42
|
+
gitlib.should_receive(:push)
|
43
|
+
pr_client.should_receive(:create).with('develop', 'master', 'master', '')
|
44
|
+
|
45
|
+
gitprocess.runner
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
it "should fail if the base and head branch are the same" do
|
50
|
+
gitlib.remote.add('origin', 'git@github.com:jdigger/git-process.git')
|
51
|
+
|
52
|
+
expect {
|
53
|
+
gitprocess.runner
|
54
|
+
}.to raise_error GitProc::PullRequestError
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
describe 'checkout pull request' do
|
61
|
+
include PullRequestHelper
|
62
|
+
|
63
|
+
before(:each) do
|
64
|
+
gitlib.config['gitProcess.github.authToken'] = 'sdfsfsdf'
|
65
|
+
gitlib.config['github.user'] = 'jdigger'
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
describe "with PR #" do
|
70
|
+
|
71
|
+
def pull_request
|
72
|
+
@pr ||= create_pull_request({})
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
def create_process(dir, opts)
|
77
|
+
GitProc::PullRequest.new(dir, opts.merge({:prNumber => pull_request[:number]}))
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
it "should checkout the branch for the pull request" do
|
82
|
+
add_remote(:head)
|
83
|
+
stub_fetch(:head)
|
84
|
+
|
85
|
+
stub_get_pull_request(pull_request)
|
86
|
+
|
87
|
+
expect_checkout_pr_head()
|
88
|
+
expect_upstream_set()
|
89
|
+
|
90
|
+
gitprocess.runner
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
describe "with repo name and PR #" do
|
97
|
+
|
98
|
+
def pull_request
|
99
|
+
@pr ||= create_pull_request(:base_remote => 'sourcerepo', :base_repo => 'source_repo')
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
def create_process(dir, opts)
|
104
|
+
GitProc::PullRequest.new(dir, opts.merge({:prNumber => pull_request[:number],
|
105
|
+
:server => pull_request[:head][:remote]}))
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
it "should checkout the branch for the pull request" do
|
110
|
+
add_remote(:head)
|
111
|
+
add_remote(:base)
|
112
|
+
stub_fetch(:head)
|
113
|
+
stub_fetch(:base)
|
114
|
+
gitlib.config['gitProcess.remoteName'] = pull_request[:head][:repo][:name]
|
115
|
+
|
116
|
+
stub_get_pull_request(pull_request)
|
117
|
+
|
118
|
+
expect_checkout_pr_head()
|
119
|
+
expect_upstream_set()
|
120
|
+
|
121
|
+
gitprocess.runner
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|