diff --git a/assets/lib/in.rb b/assets/lib/in.rb index b8cf901..4342454 100755 --- a/assets/lib/in.rb +++ b/assets/lib/in.rb @@ -19,6 +19,7 @@ def ref pr = Octokit.pull_request(input['source']['repo'], input['version']['pr']) id = pr['number'] +branch_ref = pr['head']['ref'] system("git clone --depth 1 #{uri} #{destination} 1>&2") @@ -26,11 +27,11 @@ def ref Dir.chdir(destination) do system('git submodule update --init --recursive 1>&2') - system("git fetch -q origin pull/#{id}/head:pr-#{id} 1>&2") - system("git checkout pr-#{id} 1>&2") + system("git fetch -q origin pull/#{id}/head:#{branch_ref} 1>&2") + system("git checkout #{branch_ref} 1>&2") system("git config --add pullrequest.url #{pr['html_url']} 1>&2") system("git config --add pullrequest.id #{pr['number']} 1>&2") - system("git config --add pullrequest.branch #{pr['head']['ref']} 1>&2") + system("git config --add pullrequest.branch #{branch_ref} 1>&2") end puts JSON.generate(version: { ref: ref, pr: id.to_s }, diff --git a/spec/integration/in_spec.rb b/spec/integration/in_spec.rb index 2cf8d20..b2e5f7d 100644 --- a/spec/integration/in_spec.rb +++ b/spec/integration/in_spec.rb @@ -57,10 +57,10 @@ def commit(msg) get(version: { ref: @ref, pr: '1' }, source: { uri: git_uri, repo: 'jtarchie/test' }) value = git('rev-parse --abbrev-ref HEAD', dest_dir) - expect(value).to eq 'pr-1' + expect(value).to eq 'foo' end - it 'sets original branch ref' do + it 'sets config variable to branch name' do get(version: { ref: @ref, pr: '1' }, source: { uri: git_uri, repo: 'jtarchie/test' }) value = git('config pullrequest.branch', dest_dir) expect(value).to eq 'foo'