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

Config should include the head repo name #195

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ git config --get pullrequest.body # returns the PR body
git config --get pullrequest.basebranch # returns the base branch used for the pull request
git config --get pullrequest.basesha # returns the commit of the base branch used for the pull request
git config --get pullrequest.userlogin # returns the github user login for the pull request author
git config --get pullrequest.repo # returns the full name of the source repo of the PR.
```


Expand All @@ -146,6 +147,8 @@ git config --get pullrequest.userlogin # returns the github user login for the

* `.git/body`: the body of the pull request.

* `.git/repo`: the full name of the source repo of the PR.

#### Parameters

* `git.depth`: *Optional.* If a positive integer is given, *shallow* clone the
Expand Down
2 changes: 2 additions & 0 deletions assets/lib/commands/in.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def output
File.write('base_sha', pr['base']['sha'])
File.write('userlogin', pr['user']['login'])
File.write('head_sha', pr['head']['sha'])
File.write('repo', pr['head']['repo']['full_name'])
end

Dir.chdir(destination) do
Expand All @@ -49,6 +50,7 @@ def output
git config --add pullrequest.basebranch #{pr['base']['ref'].to_s.shellescape} 1>&2
git config --add pullrequest.basesha #{pr['base']['sha'].to_s.shellescape} 1>&2
git config --add pullrequest.userlogin #{pr['user']['login'].to_s.shellescape} 1>&2
git config --add pullrequest.repo #{pr['head']['repo']['full_name'].to_s.shellescape} 1>&2
BASH

case input.params.git.submodules
Expand Down
15 changes: 8 additions & 7 deletions spec/commands/in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def dest_dir
number: 1,
head: {
ref: 'foo',
sha: 'hash'
sha: 'hash',
repo: { full_name: 'repo/name' }
},
base: {
ref: 'master',
Expand Down Expand Up @@ -173,7 +174,7 @@ def dest_dir
context 'and fetch_merge is false' do
it 'checks out as a branch named in the PR' do
stub_json('https://api.github.com:443/repos/jtarchie/test/pulls/1',
html_url: 'http://example.com', number: 1, head: { ref: 'foo' }, base: { ref: 'master', user: { login: 'jtarchie' } }, user: { login: 'jtarchie-contributor' }, mergeable: true)
html_url: 'http://example.com', number: 1, head: { ref: 'foo', repo: { full_name: 'repo/name' } }, base: { ref: 'master', user: { login: 'jtarchie' } }, user: { login: 'jtarchie-contributor' }, mergeable: true)

get('version' => { 'ref' => @ref, 'pr' => '1' }, 'source' => { 'uri' => git_uri, 'repo' => 'jtarchie/test' }, 'params' => { 'fetch_merge' => false })

Expand All @@ -183,7 +184,7 @@ def dest_dir

it 'does not fail cloning' do
stub_json('https://api.github.com:443/repos/jtarchie/test/pulls/1',
html_url: 'http://example.com', number: 1, head: { ref: 'foo' }, base: { ref: 'master', user: { login: 'jtarchie' } }, user: { login: 'jtarchie-contributor' }, mergeable: true)
html_url: 'http://example.com', number: 1, head: { ref: 'foo', repo: { full_name: 'repo/name' } }, base: { ref: 'master', user: { login: 'jtarchie' } }, user: { login: 'jtarchie-contributor' }, mergeable: true)

expect do
get('version' => { 'ref' => @ref, 'pr' => '1' }, 'source' => { 'uri' => git_uri, 'repo' => 'jtarchie/test' }, 'params' => { 'fetch_merge' => false })
Expand All @@ -194,7 +195,7 @@ def dest_dir
context 'and fetch_merge is true' do
it 'checks out the branch the PR would be merged into' do
stub_json('https://api.github.com:443/repos/jtarchie/test/pulls/1',
html_url: 'http://example.com', number: 1, head: { ref: 'foo' }, base: { ref: 'master', user: { login: 'jtarchie' } }, user: { login: 'jtarchie-contributor' }, mergeable: true)
html_url: 'http://example.com', number: 1, head: { ref: 'foo', repo: { full_name: 'repo/name' } }, base: { ref: 'master', user: { login: 'jtarchie' } }, user: { login: 'jtarchie-contributor' }, mergeable: true)

get('version' => { 'ref' => @ref, 'pr' => '1' }, 'source' => { 'uri' => git_uri, 'repo' => 'jtarchie/test' }, 'params:' => { 'fetch_merge' => true })

Expand All @@ -204,7 +205,7 @@ def dest_dir

it 'does not fail cloning' do
stub_json('https://api.github.com:443/repos/jtarchie/test/pulls/1',
html_url: 'http://example.com', number: 1, head: { ref: 'foo' }, base: { ref: 'master', user: { login: 'jtarchie' } }, user: { login: 'jtarchie-contributor' }, mergeable: true)
html_url: 'http://example.com', number: 1, head: { ref: 'foo', repo: { full_name: 'repo/name' } }, base: { ref: 'master', user: { login: 'jtarchie' } }, user: { login: 'jtarchie-contributor' }, mergeable: true)

expect do
get('version' => { 'ref' => @ref, 'pr' => '1' }, 'source' => { 'uri' => git_uri, 'repo' => 'jtarchie/test' }, 'params' => { 'fetch_merge' => true })
Expand All @@ -217,7 +218,7 @@ def dest_dir
context 'and fetch_merge is true' do
it 'raises a helpful error message' do
stub_json('https://api.github.com:443/repos/jtarchie/test/pulls/1',
html_url: 'http://example.com', number: 1, head: { ref: 'foo' }, base: { ref: 'master', user: { login: 'jtarchie' } }, user: { login: 'jtarchie-contributor' }, mergeable: false)
html_url: 'http://example.com', number: 1, head: { ref: 'foo', repo: { full_name: 'repo/name' } }, base: { ref: 'master', user: { login: 'jtarchie' } }, user: { login: 'jtarchie-contributor' }, mergeable: false)

expect do
get('version' => { 'ref' => @ref, 'pr' => '1' }, 'source' => { 'uri' => git_uri, 'repo' => 'jtarchie/test' }, 'params' => { 'fetch_merge' => true })
Expand All @@ -230,7 +231,7 @@ def dest_dir
before do
stub_json('https://api.github.com:443/repos/jtarchie/test/pulls/1',
html_url: 'http://example.com', number: 1,
head: { ref: 'foo' },
head: { ref: 'foo', repo: { full_name: 'repo/name' } },
base: { ref: 'master', user: { login: 'jtarchie' } },
user: { login: 'jtarchie-contributor' })
end
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def commit(msg)
context 'for every PR that is checked out' do
before do
proxy.stub('https://api.github.com:443/repos/jtarchie/test/pulls/1')
.and_return(json: { html_url: 'http://example.com', number: 1, head: { ref: 'foo' }, base: { ref: 'master', user: { login: 'jtarchie' } }, user: { login: 'jtarchie-contributor' } })
.and_return(json: { html_url: 'http://example.com', number: 1, head: { ref: 'foo', repo: { full_name: 'repo/name' } }, base: { ref: 'master', user: { login: 'jtarchie' } }, user: { login: 'jtarchie-contributor' } })
end

it 'checks out the pull request to dest_dir' do
Expand Down