forked from nodejs/github-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplay-travis-status.js
More file actions
34 lines (27 loc) · 998 Bytes
/
Copy pathdisplay-travis-status.js
File metadata and controls
34 lines (27 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict'
const debug = require('debug')('display_travis_status')
const pollTravis = require('../lib/pollTravis')
const enabledRepos = ['citgm', 'readable-stream', 'nodejs.org', 'docker-node']
module.exports = function (app) {
app.on('pull_request.opened', handlePrUpdate)
// Pull Request updates
app.on('pull_request.synchronize', handlePrUpdate)
function handlePrUpdate (event, owner, repo) {
if (!~enabledRepos.indexOf(repo)) return
const pr = event.number
const options = { owner, repo, pr, logger: event.logger }
debug(`/${owner}/${repo}/pull/${pr} opened`)
pollTravis.pollThenStatus(options)
}
// to trigger polling manually
app.get('/pr/:owner/:repo/:id', (req, res) => {
const owner = req.params.owner
const repo = req.params.repo
const pr = parseInt(req.params.id, 10)
const options = { owner, repo, pr, logger: req.log }
if (~enabledRepos.indexOf(repo)) {
pollTravis.pollThenStatus(options)
}
res.end()
})
}