Skip to content
This repository was archived by the owner on Nov 8, 2018. It is now read-only.

Commit f6210c9

Browse files
committed
resolve issue #33
1 parent aa6b97c commit f6210c9

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

Diff for: assets/lib/in.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def remote_ref
2323

2424
pr = Octokit.pull_request(input['source']['repo'], input['version']['pr'])
2525
id = pr['number']
26-
branch_ref = pr['head']['ref']
26+
branch_ref = "pr-#{pr['head']['ref']}"
2727

2828
raise 'PR has merge conflicts' if pr['mergeable'] == false && params['fetch_merge']
2929

@@ -37,7 +37,7 @@ def remote_ref
3737
system("git checkout #{branch_ref} 1>&2")
3838
system("git config --add pullrequest.url #{pr['html_url']} 1>&2")
3939
system("git config --add pullrequest.id #{pr['number']} 1>&2")
40-
system("git config --add pullrequest.branch #{branch_ref} 1>&2")
40+
system("git config --add pullrequest.branch #{pr['head']['ref']} 1>&2")
4141
end
4242

4343
puts JSON.generate(version: { ref: ref, pr: id.to_s },

Diff for: spec/integration/check_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@
8080

8181
before do
8282
proxy.stub('https://api.github.com:443/repos/jtarchie/test/pulls?direction=asc&per_page=100&sort=updated&state=open')
83-
.and_return(json: [
84-
{ number: 1, head: { sha: 'abcdef' } },
85-
{ number: 2, head: { sha: 'zyxwvu' } }
86-
])
83+
.and_return(json: [
84+
{ number: 1, head: { sha: 'abcdef' } },
85+
{ number: 2, head: { sha: 'zyxwvu' } }
86+
])
8787
end
8888

8989
it 'returns all PRs oldest to newest last' do

Diff for: spec/integration/in_spec.rb

+21-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def commit(msg)
2626
commit('second')
2727

2828
git("update-ref refs/pull/1/head #{@ref}")
29+
git("update-ref refs/pull/1/merge #{@ref}")
2930
end
3031

3132
context 'for every PR that is checked out' do
@@ -55,11 +56,11 @@ def commit(msg)
5556
expect(value).to eq 'http://example.com'
5657
end
5758

58-
it 'checks out as a branch' do
59+
it 'checks out as a branch with a `pr-` prefix' do
5960
get(version: { ref: @ref, pr: '1' }, source: { uri: git_uri, repo: 'jtarchie/test' })
6061

6162
value = git('rev-parse --abbrev-ref HEAD', dest_dir)
62-
expect(value).to eq 'foo'
63+
expect(value).to eq 'pr-foo'
6364
end
6465

6566
it 'sets config variable to branch name' do
@@ -92,7 +93,15 @@ def commit(msg)
9293
get(version: { ref: @ref, pr: '1' }, source: { uri: git_uri, repo: 'jtarchie/test' }, params: { fetch_merge: false })
9394

9495
value = git('rev-parse --abbrev-ref HEAD', dest_dir)
95-
expect(value).to eq 'foo'
96+
expect(value).to eq 'pr-foo'
97+
end
98+
99+
it 'does not fail cloning' do
100+
proxy.stub('https://api.github.com:443/repos/jtarchie/test/pulls/1')
101+
.and_return(json: { html_url: 'http://example.com', number: 1, head: { ref: 'foo' }, mergeable: true })
102+
103+
_, error = get(version: { ref: @ref, pr: '1' }, source: { uri: git_uri, repo: 'jtarchie/test' }, params: { fetch_merge: false })
104+
expect(error).not_to include 'git clone failed'
96105
end
97106
end
98107

@@ -104,7 +113,15 @@ def commit(msg)
104113
get(version: { ref: @ref, pr: '1' }, source: { uri: git_uri, repo: 'jtarchie/test' }, params: { fetch_merge: true })
105114

106115
value = git('rev-parse --abbrev-ref HEAD', dest_dir)
107-
expect(value).to eq 'master'
116+
expect(value).to eq 'pr-foo'
117+
end
118+
119+
it 'does not fail cloning' do
120+
proxy.stub('https://api.github.com:443/repos/jtarchie/test/pulls/1')
121+
.and_return(json: { html_url: 'http://example.com', number: 1, head: { ref: 'foo' }, mergeable: true })
122+
123+
_, error = get(version: { ref: @ref, pr: '1' }, source: { uri: git_uri, repo: 'jtarchie/test' }, params: { fetch_merge: true })
124+
expect(error).not_to include 'git clone failed'
108125
end
109126
end
110127
end

0 commit comments

Comments
 (0)