Skip to content

Commit 364d363

Browse files
bcutler-workThomas Osugi
authored andcommitted
Save original branch name from PR to git config variable
Signed-off-by: Thomas Osugi <tosugi@pivotal.io>
1 parent 30aba90 commit 364d363

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

assets/lib/in.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def ref
3030
system("git checkout pr-#{id} 1>&2")
3131
system("git config --add pullrequest.url #{pr['html_url']} 1>&2")
3232
system("git config --add pullrequest.id #{pr['number']} 1>&2")
33+
system("git config --add pullrequest.branch #{pr['head']['ref']} 1>&2")
3334
end
3435

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

spec/integration/in_spec.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def commit(msg)
2323

2424
before do
2525
proxy.stub('https://api.github.com:443/repos/jtarchie/test/pulls/1')
26-
.and_return(json: { html_url: 'http://example.com', number: 1 })
26+
.and_return(json: { html_url: 'http://example.com', number: 1, head: { ref: 'foo' } })
2727

2828
git('init -q')
2929
@ref = commit('init')
@@ -60,6 +60,12 @@ def commit(msg)
6060
expect(value).to eq 'pr-1'
6161
end
6262

63+
it 'sets original branch ref' do
64+
get(version: { ref: @ref, pr: '1' }, source: { uri: git_uri, repo: 'jtarchie/test' })
65+
value = git('config pullrequest.branch', dest_dir)
66+
expect(value).to eq 'foo'
67+
end
68+
6369
context 'when the git clone fails' do
6470
it 'provides a helpful erorr message' do
6571
_, error = get(version: { ref: @ref, pr: '1' }, source: { uri: 'invalid_git_uri', repo: 'jtarchie/test' })

0 commit comments

Comments
 (0)