Skip to content

Commit

Permalink
fix: correctly detect if pull request for a release branch is open
Browse files Browse the repository at this point in the history
When using `head` in the pull request api https://developer.github.com/v3/pulls/#list-pull-requests,
it is required to specify a head user/organization. Otherwise the result
will contain also other branches and the action falsely detects open pull requests
  • Loading branch information
patrickjahns committed Mar 1, 2020
1 parent aa7cb04 commit d4fb45b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/pull-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function createOrUpdatePr(env, commit_msg, body) {
const { data: pr } = await env.octokit.pulls.list({
state: 'open',
base: env.config.base_branch,
head: `${env.config.release_branch}`,
head: `${env.repo_context.owner}:${env.config.release_branch}`,
...env.repo_context
})

Expand Down
8 changes: 4 additions & 4 deletions test/pull-request.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ describe('pull-request', () => {
}
nock('https://api.github.com')
.get('/repos/patrickjahns/chlgr/pulls')
.query({ state: 'open', base: 'master', head: 'release/next' })
.query({ state: 'open', base: 'master', head: 'patrickjahns:release/next' })
.reply(200, [])
nock('https://api.github.com')
.post('/repos/patrickjahns/chlgr/pulls', body => {
expect(body).toMatchObject({
body: `test`,
title: `test`,
body: 'test',
title: 'test',
head: 'release/next',
base: 'master',
maintainer_can_modify: true
Expand All @@ -56,7 +56,7 @@ describe('pull-request', () => {
}
nock('https://api.github.com')
.get('/repos/patrickjahns/chlgr/pulls')
.query({ state: 'open', base: 'master', head: 'release/next' })
.query({ state: 'open', base: 'master', head: 'patrickjahns:release/next' })
.reply(200, require('./fixtures/open_pull_request'))
nock('https://api.github.com')
.patch('/repos/patrickjahns/chlgr/pulls/5', body => {
Expand Down

0 comments on commit d4fb45b

Please sign in to comment.