Skip to content

Commit

Permalink
feat: Add 'assigned' label to pull request submitted issue (#24)
Browse files Browse the repository at this point in the history
* feat: Add 'assigned' label to pull request submitted issue

* test: Change test label from test to invalid
  • Loading branch information
potato4d authored and re-fort committed Feb 4, 2019
1 parent 08e1fdd commit f058ba4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Expand Up @@ -139,6 +139,8 @@ const after = async (item, shortHash, issueNo = null) => {
Utility.log('S', `Created new pull request: ${pullRequest.html_url}`)
await github.assignReviewers(remote, { number: pullRequest.number, reviewers: ['re-fort', 'kazupon', 'potato4d'] })
Utility.log('S', 'Assigned reviewers')
await github.addLabels(remote, { number: issueNo, labels: ['assigned'] })
Utility.log('S', 'Added "assigned" label to issue')
}

process.on('unhandledRejection', err => { Utility.log('E', err) })
Expand Down
13 changes: 13 additions & 0 deletions lib/github.js
Expand Up @@ -40,6 +40,19 @@ class GitHub {
})
}

addLabels(remote, params = {}) {
return new Promise((resolve, reject) => {
this.github.issues.addLabels({
owner: remote.upstream.owner,
repo: remote.upstream.name,
number: params.number,
labels: params.labels,
})
.then(res => resolve(res))
.catch(err => reject(err))
})
}

searchIssue(remote, params = {}) {
return new Promise((resolve, reject) => {
this.github.search.issues({
Expand Down
9 changes: 9 additions & 0 deletions test/lib/github.js
Expand Up @@ -42,6 +42,15 @@ describe('Github', function () {
assert(closedIssue.state === 'closed')
})
})

describe('createLabels()', function () {
it('creates new label', async function () {
const { data: newIssue } = await github.createIssue(remote, { title: 'Test', body: `Test\r\nOriginal:${url}`, labels: ['documentation'] })

const { data: result } = await github.addLabels(remote, { number: newIssue.number, labels: ['invalid'] })
assert(result.length === 2)
})
})
})

describe('pullRequest', function () {
Expand Down

0 comments on commit f058ba4

Please sign in to comment.