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

Commit 6a5b6df

Browse files
committed
include PR author user_login in metadata
1 parent bd51f6f commit 6a5b6df

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ git config --get pullrequest.url # returns the URL to the pull request
112112
git config --get pullrequest.branch # returns the branch name used for the pull request
113113
git config --get pullrequest.id # returns the ID number of the PR
114114
git config --get pullrequest.basebranch # returns the base branch used for the pull request
115+
git config --get pullrequest.userlogin # returns the github user login for the pull request author
115116
```
116117

117118

@@ -125,10 +126,12 @@ git config --get pullrequest.basebranch # returns the base branch used for the p
125126

126127
* `.git/base_branch`: the base branch of the pull request
127128

129+
* `.git/user_login`: the user login of the pull request author
130+
128131
#### Parameters
129132

130133
* `git.depth`: *Optional.* If a positive integer is given, *shallow* clone the
131-
repository using the `--depth` option.
134+
repository using the `--depth` option.
132135

133136
* `git.submodules`: *Optional*, default `all`. If `none`, submodules will not be
134137
fetched. If specified as a list of paths, only the given paths will be
@@ -158,7 +161,7 @@ Set the status message for `concourse-ci` context on specified pull request.
158161
This supports the [build environment](http://concourse.ci/implementing-resources.html#resource-metadata)
159162
variables provided by concourse. For example, `context: $BUILD_JOB_NAME` will set the context to the job name.
160163

161-
* `comment`: *Optional.* The file path of the comment message. Comment owner is same with the owner of `access_token`.
164+
* `comment`: *Optional.* The file path of the comment message. Comment owner is same with the owner of `access_token`.
162165

163166
* `merge.method`: *Optional.* Use this to merge the PR into the target branch of the PR. There are three available merge methods -- `merge`, `squash`, or `rebase`. Please this [doc](https://developer.github.com/changes/2016-09-26-pull-request-merge-api-update/) for more information.
164167

@@ -179,4 +182,3 @@ Requires `ruby` to be installed.
179182
bundle install
180183
bundle exec rspec
181184
```
182-

assets/lib/commands/in.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def output
3030
echo "#{pr['number']}" > id
3131
echo "#{pr['head']['ref']}" > branch
3232
echo "#{pr['base']['ref']}" > base_branch
33+
echo "#{pr['base']['user']['login']}" > userlogin
3334
BASH
3435
end
3536

@@ -42,6 +43,7 @@ def output
4243
git config --add pullrequest.id #{pr['number']} 1>&2
4344
git config --add pullrequest.branch #{pr['head']['ref']} 1>&2
4445
git config --add pullrequest.basebranch #{pr['base']['ref']} 1>&2
46+
git config --add pullrequest.userlogin #{pr['base']['user']['login']} 1>&2
4547
BASH
4648

4749
case input.params.git.submodules

spec/commands/in_spec.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def dest_dir
5252
end
5353

5454
before(:all) do
55-
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' })
55+
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' } })
5656
@output = get('version' => { 'ref' => @ref, 'pr' => '1' }, 'source' => { 'uri' => git_uri, 'repo' => 'jtarchie/test' })
5757
end
5858

@@ -88,6 +88,11 @@ def dest_dir
8888
expect(value).to eq 'master'
8989
end
9090

91+
it 'sets config variable to user_login name' do
92+
value = git('config pullrequest.userlogin', dest_dir)
93+
expect(value).to eq 'jtarchie'
94+
end
95+
9196
it 'creates a file that icludes the id in the .git folder' do
9297
value = File.read(File.join(dest_dir,'.git','id')).strip()
9398
expect(value).to eq '1'
@@ -112,7 +117,7 @@ def dest_dir
112117

113118
context 'when the git clone fails' do
114119
it 'provides a helpful erorr message' do
115-
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' })
120+
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' } })
116121

117122
expect do
118123
get('version' => { 'ref' => @ref, 'pr' => '1' }, 'source' => { 'uri' => 'invalid_git_uri', 'repo' => 'jtarchie/test' })
@@ -125,7 +130,7 @@ def dest_dir
125130
context 'and fetch_merge is false' do
126131
it 'checks out as a branch named in the PR' do
127132
stub_json('https://api.github.com:443/repos/jtarchie/test/pulls/1',
128-
html_url: 'http://example.com', number: 1, head: { ref: 'foo' }, base: { ref: 'master' }, mergeable: true)
133+
html_url: 'http://example.com', number: 1, head: { ref: 'foo' }, base: { ref: 'master', user: { login: 'jtarchie' } }, mergeable: true)
129134

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

@@ -135,7 +140,7 @@ def dest_dir
135140

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

140145
expect do
141146
get('version' => { 'ref' => @ref, 'pr' => '1' }, 'source' => { 'uri' => git_uri, 'repo' => 'jtarchie/test' }, 'params' => { 'fetch_merge' => false })
@@ -146,7 +151,7 @@ def dest_dir
146151
context 'and fetch_merge is true' do
147152
it 'checks out the branch the PR would be merged into' do
148153
stub_json('https://api.github.com:443/repos/jtarchie/test/pulls/1',
149-
html_url: 'http://example.com', number: 1, head: { ref: 'foo' }, base: { ref: 'master' }, mergeable: true)
154+
html_url: 'http://example.com', number: 1, head: { ref: 'foo' }, base: { ref: 'master', user: { login: 'jtarchie' } }, mergeable: true)
150155

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

@@ -156,7 +161,7 @@ def dest_dir
156161

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

161166
expect do
162167
get('version' => { 'ref' => @ref, 'pr' => '1' }, 'source' => { 'uri' => git_uri, 'repo' => 'jtarchie/test' }, 'params' => { 'fetch_merge' => true })
@@ -169,7 +174,7 @@ def dest_dir
169174
context 'and fetch_merge is true' do
170175
it 'raises a helpful error message' do
171176
stub_json('https://api.github.com:443/repos/jtarchie/test/pulls/1',
172-
html_url: 'http://example.com', number: 1, head: { ref: 'foo' }, base: { ref: 'master' }, mergeable: false)
177+
html_url: 'http://example.com', number: 1, head: { ref: 'foo' }, base: { ref: 'master', user: { login: 'jtarchie' } }, mergeable: false)
173178

174179
expect do
175180
get('version' => { 'ref' => @ref, 'pr' => '1' }, 'source' => { 'uri' => git_uri, 'repo' => 'jtarchie/test' }, 'params' => { 'fetch_merge' => true })
@@ -183,7 +188,7 @@ def dest_dir
183188
stub_json('https://api.github.com:443/repos/jtarchie/test/pulls/1',
184189
html_url: 'http://example.com', number: 1,
185190
head: { ref: 'foo' },
186-
base: { ref: 'master' })
191+
base: { ref: 'master', user: { login: 'jtarchie' } })
187192
end
188193

189194
def expect_arg(*args)

spec/integration/in_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def commit(msg)
3535
context 'for every PR that is checked out' do
3636
before do
3737
proxy.stub('https://api.github.com:443/repos/jtarchie/test/pulls/1')
38-
.and_return(json: { html_url: 'http://example.com', number: 1, head: { ref: 'foo' }, base: { ref: 'master' } })
38+
.and_return(json: { html_url: 'http://example.com', number: 1, head: { ref: 'foo' }, base: { ref: 'master', user: { login: 'jtarchie' } } })
3939
end
4040

4141
it 'checks out the pull request to dest_dir' do

0 commit comments

Comments
 (0)