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

Commit

Permalink
check out original branch name instead of pr-{id}
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Cutler <bcutler@pivotal.io>
  • Loading branch information
Thomas Osugi authored and bcutler-work committed May 25, 2016
1 parent 364d363 commit a819d7e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions assets/lib/in.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ 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")

raise 'git clone failed' unless $CHILD_STATUS.exitstatus == 0

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 },
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit a819d7e

Please sign in to comment.