in src/server/webhooks/pull_request.js [61:111]
async function updateStatusAndComment(args, item) {
try {
const committers = await repoService.getPRCommitters(args)
if (committers && committers.length > 0) {
const promises = []
let checkResult
try {
checkResult = await cla.check(args, item)
logger.debug(`pullRequestWebhook-->updateStatusAndComment for the repo ${args.owner}/${args.repo}/pull/${args.number}`)
} catch (error) {
logger.warn(new Error(error).stack)
}
args.signed = checkResult.signed
if (!checkResult.userMap ||
(checkResult.userMap.signed && checkResult.userMap.signed.length > 0) ||
(checkResult.userMap.not_signed && checkResult.userMap.not_signed.length > 0) ||
(checkResult.userMap.unknown && checkResult.userMap.unknown.length > 0)
) {
promises.push(status.update(args))
} else {
promises.push(status.updateForClaNotRequired(args))
}
promises.push(pullRequest.badgeComment(
args.owner,
args.repo,
args.number,
checkResult.signed,
checkResult.userMap
))
if (checkResult.userMap && checkResult.userMap.not_signed) {
storeRequest(checkResult.userMap.not_signed, args.repo, args.owner, args.number)
}
try {
await Promise.all(promises)
} catch (error) {
logger.warn(new Error(`Could not update status and/or comment on PR. Args: ${args}`).stack)
}
} else {
logger.warn(new Error(`No committers found for the PR. Args: ${args}`).stack)
}
} catch (error) {
if (!args.handleCount || args.handleCount < 2) {
args.handleCount = args.handleCount ? ++args.handleCount : 1
setTimeout(function () {
updateStatusAndComment(args)
}, 10000 * args.handleCount * args.handleDelay)
} else {
logger.warn(new Error(error).stack, 'updateStatusAndComment called with args: ', args)
}
}
}