Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions lib/node-repo.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
'use strict'

const LRU = require('lru-cache')
const retry = require('async').retry

const githubClient = require('./github-client')
const resolveLabels = require('./node-labels').resolveLabels
const existingLabelsCache = new LRU({ max: 1, maxAge: 1000 * 60 * 60 })

const fiveSeconds = 5 * 1000

function deferredResolveLabelsThenUpdatePr (options) {
const timeoutMillis = (options.timeoutInSec || 0) * 1000
setTimeout(resolveLabelsThenUpdatePr, timeoutMillis, options)
Expand All @@ -14,11 +17,15 @@ function deferredResolveLabelsThenUpdatePr (options) {
function resolveLabelsThenUpdatePr (options) {
options.logger.debug('Fetching PR files for labelling')

githubClient.pullRequests.getFiles({
owner: options.owner,
repo: options.repo,
number: options.prId
}, (err, res) => {
const getFiles = (cb) => {
githubClient.pullRequests.getFiles({
owner: options.owner,
repo: options.repo,
number: options.prId
}, cb)
}

retry({ times: 5, interval: fiveSeconds }, getFiles, (err, res) => {
if (err) {
return options.logger.error(err, 'Error retrieving files from GitHub')
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"private": true,
"license": "MIT",
"dependencies": {
"async": "2.1.5",
"basic-auth": "^1.0.4",
"body-parser": "^1.15.0",
"bunyan": "^1.8.1",
Expand Down