2017-12-18 08:39:52 +00:00
module . exports = {
raiseConfigWarningIssue ,
} ;
async function raiseConfigWarningIssue ( config , error ) {
logger . debug ( 'raiseConfigWarningIssue()' ) ;
2018-03-22 10:55:58 +00:00
let body = ` There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved. \n \n ` ;
2017-12-18 08:39:52 +00:00
if ( error . configFile ) {
2018-03-22 10:55:58 +00:00
body += ` File: \` ${ error . configFile } \` \n ` ;
2017-12-18 08:39:52 +00:00
}
body += ` Error type: ${ error . validationError } \n ` ;
if ( error . validationMessage ) {
body += ` Message: ${ error . validationMessage } \n ` ;
}
2018-01-08 14:53:52 +00:00
const pr = await platform . getBranchPr ( 'renovate/configure' ) ;
if ( pr && pr . state && pr . state . startsWith ( 'open' ) ) {
logger . info ( 'Updating onboarding PR with config error notice' ) ;
body = ` ## Action Required: Fix Renovate Configuration \n \n ${ body } ` ;
body += ` \n \n Once you have resolved this problem (in this onboarding branch), Renovate will return to providing you with a preview of your repository's configuration. ` ;
await platform . updatePr ( pr . number , 'Configure Renovate' , body ) ;
} else {
2017-12-18 08:39:52 +00:00
const res = await platform . ensureIssue (
'Action Required: Fix Renovate Configuration' ,
body
) ;
2018-03-22 10:55:58 +00:00
if ( res === 'created' ) {
2017-12-18 08:39:52 +00:00
logger . warn ( { configError : error , res } , 'Config Warning' ) ;
}
}
}