2018-07-14 05:50:37 +00:00
const { DateTime } = require ( 'luxon' ) ;
2017-07-07 04:25:38 +00:00
const schedule = require ( './schedule' ) ;
2018-05-09 06:03:59 +00:00
const { getUpdatedPackageFiles } = require ( './get-updated' ) ;
const { getAdditionalFiles } = require ( '../../manager/npm/post-update' ) ;
2017-08-26 14:10:18 +00:00
const { commitFilesToBranch } = require ( './commit' ) ;
const { getParentBranch } = require ( './parent' ) ;
const { tryBranchAutomerge } = require ( './automerge' ) ;
const { setUnpublishable } = require ( './status-checks' ) ;
const { prAlreadyExisted } = require ( './check-existing' ) ;
2017-06-29 05:29:41 +00:00
const prWorker = require ( '../pr' ) ;
2019-01-06 13:47:42 +00:00
const { appName , appSlug } = require ( '../../config/app-strings' ) ;
2017-08-26 14:10:18 +00:00
const { isScheduledNow } = schedule ;
2017-02-14 07:08:40 +00:00
module . exports = {
2017-08-26 14:10:18 +00:00
processBranch ,
2017-02-14 07:08:40 +00:00
} ;
2018-10-03 13:57:01 +00:00
async function processBranch ( branchConfig , prHourlyLimitReached , packageFiles ) {
2017-08-26 14:10:18 +00:00
const config = { ... branchConfig } ;
2017-12-15 20:33:54 +00:00
const dependencies = config . upgrades
2017-08-26 14:10:18 +00:00
. map ( upgrade => upgrade . depName )
2017-12-15 20:33:54 +00:00
. filter ( v => v ) // remove nulls (happens for lock file maintenance)
. filter ( ( value , i , list ) => list . indexOf ( value ) === i ) ; // remove duplicates
2017-11-08 05:44:03 +00:00
logger . setMeta ( {
2017-08-26 14:10:18 +00:00
repository : config . repository ,
branch : config . branchName ,
dependencies ,
} ) ;
2018-10-15 07:21:57 +00:00
logger . debug ( ` processBranch with ${ branchConfig . upgrades . length } upgrades ` ) ;
2018-01-11 10:49:01 +00:00
logger . trace ( { config } ) ;
2018-01-12 06:47:18 +00:00
await platform . setBaseBranch ( config . baseBranch ) ;
2018-01-11 10:49:01 +00:00
const branchExists = await platform . branchExists ( config . branchName ) ;
2018-10-03 14:01:57 +00:00
const branchPr = await platform . getBranchPr ( config . branchName ) ;
2018-01-11 10:49:01 +00:00
logger . debug ( ` branchExists= ${ branchExists } ` ) ;
2018-10-04 08:07:59 +00:00
const masterIssueCheck = ( config . masterIssueChecks || { } ) [ config . branchName ] ;
// istanbul ignore if
if ( masterIssueCheck ) {
logger . info ( 'Branch has been checked in master issue: ' + masterIssueCheck ) ;
}
2017-08-26 14:10:18 +00:00
try {
2018-09-05 12:18:31 +00:00
logger . debug (
2018-02-11 18:58:59 +00:00
` Branch has ${ dependencies ? dependencies . length : 0 } upgrade(s) `
) ;
2017-06-29 17:50:26 +00:00
2017-11-10 12:32:33 +00:00
// Check if branch already existed
2018-10-03 14:01:57 +00:00
const existingPr = branchPr ? undefined : await prAlreadyExisted ( config ) ;
2018-10-04 08:07:59 +00:00
if ( existingPr && ! masterIssueCheck ) {
2018-09-11 07:11:59 +00:00
logger . debug (
2017-10-18 19:39:10 +00:00
{ prTitle : config . prTitle } ,
'Closed PR already exists. Skipping branch.'
) ;
2018-05-30 09:03:30 +00:00
if ( existingPr . state === 'closed' ) {
2019-01-06 13:47:42 +00:00
const subject = ` ${ appName } Ignore Notification ` ;
2018-01-20 14:03:57 +00:00
let content ;
2018-07-04 08:11:53 +00:00
if ( config . updateType === 'major' ) {
2019-01-06 13:47:42 +00:00
content = ` As this PR has been closed unmerged, ${ appName } will ignore this upgrade and you will not receive PRs for *any* future ${
2018-06-04 03:48:20 +00:00
config . newMajor
2018-01-20 14:03:57 +00:00
} . x releases . However , if you upgrade to $ {
2018-06-04 03:48:20 +00:00
config . newMajor
2019-01-06 13:47:42 +00:00
} . x manually then $ { appName } will then reenable updates for minor and patch updates automatically . ` ;
2018-07-04 08:11:53 +00:00
} else if ( config . updateType === 'digest' ) {
2019-01-06 13:47:42 +00:00
content = ` As this PR has been closed unmerged, ${ appName } will ignore this upgrade updateType and you will not receive PRs for *any* future ${
2018-01-20 14:03:57 +00:00
config . depName
} : $ {
2018-12-10 03:26:14 +00:00
config . currentValue
2018-01-20 14:03:57 +00:00
} digest updates . Digest updates will resume if you update the specified tag at any time . ` ;
} else {
2019-01-06 13:47:42 +00:00
content = ` As this PR has been closed unmerged, ${ appName } will now ignore this update ( ${
2018-06-04 03:48:20 +00:00
config . newValue
2018-01-20 14:03:57 +00:00
} ) . You will still receive a PR once a newer version is released , so if you wish to permanently ignore this dependency , please add it to the \ ` ignoreDeps \` array of your renovate config. ` ;
}
content +=
2018-01-23 09:50:05 +00:00
'\n\nIf this PR was closed by mistake or you changed your mind, you can simply rename this PR and you will soon get a fresh replacement PR opened.' ;
2018-12-08 11:42:56 +00:00
if ( ! config . suppressNotifications . includes ( 'prIgnoreNotification' ) ) {
// istanbul ignore if
if ( config . dryRun ) {
logger . info (
'DRY-RUN: Would ensure closed PR comment in PR #' +
existingPr . number
) ;
} else {
await platform . ensureComment ( existingPr . number , subject , content ) ;
}
2018-10-26 07:48:49 +00:00
}
2018-01-20 14:03:57 +00:00
if ( branchExists ) {
2018-10-26 07:48:49 +00:00
// istanbul ignore if
if ( config . dryRun ) {
logger . info ( 'DRY-RUN: Would delete branch ' + config . branchName ) ;
} else {
await platform . deleteBranch ( config . branchName ) ;
}
2018-01-20 14:03:57 +00:00
}
2018-05-30 09:03:30 +00:00
} else if ( existingPr . state === 'merged' ) {
logger . info (
{ pr : existingPr . number } ,
'Merged PR is blocking this branch'
) ;
2018-01-10 09:26:57 +00:00
}
2017-08-28 13:50:11 +00:00
return 'already-existed' ;
2017-08-06 13:38:10 +00:00
}
2018-10-04 09:22:31 +00:00
// istanbul ignore if
if ( ! branchExists && config . masterIssueApproval ) {
if ( masterIssueCheck ) {
logger . info ( ` Branch ${ config . branchName } is approved for creation ` ) ;
} else {
logger . info ( ` Branch ${ config . branchName } needs approval ` ) ;
return 'needs-approval' ;
}
}
2018-10-04 08:07:59 +00:00
if ( ! branchExists && prHourlyLimitReached && ! masterIssueCheck ) {
2018-10-03 14:00:58 +00:00
logger . info ( 'Reached PR creation limit - skipping branch creation' ) ;
return 'pr-hourly-limit-reached' ;
}
2018-02-28 03:43:30 +00:00
if ( branchExists ) {
logger . debug ( 'Checking if PR has been edited' ) ;
2018-05-30 09:03:30 +00:00
if ( branchPr ) {
2018-06-01 17:33:52 +00:00
logger . debug ( 'Found existing branch PR' ) ;
2018-06-26 09:20:26 +00:00
if ( branchPr . state !== 'open' ) {
logger . info (
'PR has been closed or merged since this run started - aborting'
) ;
throw new Error ( 'repository-changed' ) ;
}
2018-05-30 09:03:30 +00:00
if ( ! branchPr . canRebase ) {
2017-12-28 15:29:03 +00:00
const subject = 'PR has been edited' ;
2018-09-27 14:22:27 +00:00
const titleRebase =
branchPr . title && branchPr . title . startsWith ( 'rebase!' ) ;
const labelRebase =
branchPr . labels && branchPr . labels . includes ( config . rebaseLabel ) ;
2019-02-16 10:41:43 +00:00
const prRebaseChecked =
branchPr . body &&
branchPr . body . includes ( ` - [x] <!-- ${ appSlug } -rebase --> ` ) ;
if ( prRebaseChecked || titleRebase || labelRebase ) {
2018-10-26 07:48:49 +00:00
// istanbul ignore if
if ( config . dryRun ) {
logger . info (
'DRY-RUN: Would ensure PR edited comment removal in PR #' +
branchPr . number
) ;
} else {
await platform . ensureCommentRemoval ( branchPr . number , subject ) ;
}
2018-09-20 14:10:14 +00:00
} else {
2019-01-06 13:47:42 +00:00
let content = ` :construction_worker: This PR has received other commits, so ${ appName } will stop updating it to avoid conflicts or other problems. ` ;
2019-02-11 09:43:20 +00:00
content += ` If you wish to abandon your changes and have ${ appName } start over you may click the "rebase" checkbox in the PR body/description. ` ;
2018-12-08 11:42:56 +00:00
if ( ! config . suppressNotifications . includes ( 'prEditNotification' ) ) {
// istanbul ignore if
if ( config . dryRun ) {
logger . info (
'DRY-RUN: ensure comment in PR #' + branchPr . number
) ;
} else {
await platform . ensureComment ( branchPr . number , subject , content ) ;
}
2018-10-26 07:48:49 +00:00
}
2018-09-20 14:10:14 +00:00
return 'pr-edited' ;
}
2017-12-28 15:29:03 +00:00
}
2017-12-27 14:20:32 +00:00
}
}
2017-11-10 12:32:33 +00:00
// Check schedule
config . isScheduledNow = isScheduledNow ( config ) ;
2018-10-04 08:07:59 +00:00
if ( ! config . isScheduledNow && ! masterIssueCheck ) {
2018-01-11 10:49:01 +00:00
if ( ! branchExists ) {
2017-11-10 12:32:33 +00:00
logger . info ( 'Skipping branch creation as not within schedule' ) ;
return 'not-scheduled' ;
}
if ( config . updateNotScheduled === false ) {
logger . debug ( 'Skipping branch update as not within schedule' ) ;
return 'not-scheduled' ;
}
2018-09-13 07:08:25 +00:00
// istanbul ignore if
2018-09-19 05:07:04 +00:00
if ( ! branchPr ) {
logger . debug ( 'Skipping PR creation out of schedule' ) ;
2018-09-13 07:08:25 +00:00
return 'not-scheduled' ;
}
2017-11-10 12:32:33 +00:00
logger . debug (
2018-09-19 05:07:04 +00:00
'Branch + PR exists but is not scheduled -- will update if necessary'
2017-11-10 12:32:33 +00:00
) ;
}
2018-03-21 10:40:13 +00:00
if (
2018-07-04 08:11:53 +00:00
config . updateType !== 'lockFileMaintenance' &&
2018-03-21 10:40:13 +00:00
config . unpublishSafe &&
2018-06-04 12:56:47 +00:00
config . canBeUnpublished &&
2018-03-21 10:40:13 +00:00
( config . prCreation === 'not-pending' ||
config . prCreation === 'status-success' )
) {
logger . info (
'Skipping branch creation due to unpublishSafe + status checks'
) ;
return 'pending' ;
}
2018-10-04 08:07:59 +00:00
// istanbul ignore if
if ( masterIssueCheck === 'rebase' ) {
logger . info ( 'Manual rebase requested via master issue' ) ;
delete config . parentBranch ;
} else {
Object . assign ( config , await getParentBranch ( config ) ) ;
}
2017-08-26 14:10:18 +00:00
logger . debug ( ` Using parentBranch: ${ config . parentBranch } ` ) ;
2018-10-01 16:15:06 +00:00
const res = await getUpdatedPackageFiles ( config ) ;
// istanbul ignore if
2019-02-08 13:31:30 +00:00
if ( res . artifactErrors && config . artifactErrors ) {
res . artifactErrors = config . artifactErrors . concat ( res . artifactErrors ) ;
2018-10-01 16:15:06 +00:00
}
Object . assign ( config , res ) ;
2018-02-11 18:58:59 +00:00
if ( config . updatedPackageFiles && config . updatedPackageFiles . length ) {
2017-08-26 14:10:18 +00:00
logger . debug (
` Updated ${ config . updatedPackageFiles . length } package files `
2017-04-21 08:12:41 +00:00
) ;
2017-08-26 14:10:18 +00:00
} else {
logger . debug ( 'No package files need updating' ) ;
2017-04-15 18:32:01 +00:00
}
2018-07-18 18:10:50 +00:00
const additionalFiles = await getAdditionalFiles ( config , packageFiles ) ;
2019-02-08 13:31:30 +00:00
config . artifactErrors = ( config . artifactErrors || [ ] ) . concat (
additionalFiles . artifactErrors
2018-10-01 16:15:06 +00:00
) ;
2019-02-08 13:31:30 +00:00
config . updatedArtifacts = ( config . updatedArtifacts || [ ] ) . concat (
additionalFiles . updatedArtifacts
2018-07-18 18:10:50 +00:00
) ;
2019-02-08 13:31:30 +00:00
if ( config . updatedArtifacts && config . updatedArtifacts . length ) {
2017-08-26 14:10:18 +00:00
logger . debug (
2019-02-08 13:31:30 +00:00
{ updatedArtifacts : config . updatedArtifacts . map ( f => f . name ) } ,
` Updated ${ config . updatedArtifacts . length } lock files `
2017-08-08 21:03:52 +00:00
) ;
2017-08-26 14:10:18 +00:00
} else {
logger . debug ( 'No updated lock files in branch' ) ;
2017-08-08 21:03:52 +00:00
}
2019-02-08 13:31:30 +00:00
if ( config . artifactErrors && config . artifactErrors . length ) {
2018-07-14 05:50:37 +00:00
if ( config . releaseTimestamp ) {
logger . debug ( ` Branch timestamp: ` + config . releaseTimestamp ) ;
const releaseTimestamp = DateTime . fromISO ( config . releaseTimestamp ) ;
if ( releaseTimestamp . plus ( { days : 1 } ) < DateTime . local ( ) ) {
logger . info ( 'PR is older than a day, raise PR with lock file errors' ) ;
} else if ( branchExists ) {
logger . info (
'PR is less than a day old but branchExists so updating anyway'
) ;
} else {
logger . info ( 'PR is less than a day old - raise error instead of PR' ) ;
throw new Error ( 'lockfile-error' ) ;
}
} else {
logger . debug ( 'PR has no releaseTimestamp' ) ;
}
}
2018-01-11 10:49:01 +00:00
2018-09-03 19:29:23 +00:00
config . committedFiles = await commitFilesToBranch ( config ) ;
2018-05-06 10:26:21 +00:00
// istanbul ignore if
2018-03-20 05:48:27 +00:00
if (
2018-07-04 08:11:53 +00:00
config . updateType === 'lockFileMaintenance' &&
2018-09-03 19:29:23 +00:00
! config . committedFiles &&
2018-03-21 14:53:48 +00:00
! config . parentBranch &&
branchExists
2018-03-20 05:48:27 +00:00
) {
2018-04-05 05:04:02 +00:00
logger . info (
2018-03-16 09:40:07 +00:00
'Deleting lock file maintenance branch as master lock file no longer needs updating'
) ;
2018-10-26 07:48:49 +00:00
// istanbul ignore if
if ( config . dryRun ) {
logger . info ( 'DRY-RUN: Would delete lock file maintenance branch' ) ;
} else {
await platform . deleteBranch ( config . branchName ) ;
}
2018-05-06 10:26:21 +00:00
return 'done' ;
2018-03-16 09:40:07 +00:00
}
2018-09-03 19:29:23 +00:00
if ( ! ( config . committedFiles || branchExists ) ) {
2017-11-27 07:25:07 +00:00
return 'no-work' ;
}
2017-08-26 14:10:18 +00:00
// Set branch statuses
await setUnpublishable ( config ) ;
2018-07-02 07:33:45 +00:00
// Try to automerge branch and finish if successful, but only if branch already existed before this run
if ( branchExists || ! config . requiresStatusChecks ) {
const mergeStatus = await tryBranchAutomerge ( config ) ;
logger . debug ( ` mergeStatus= ${ mergeStatus } ` ) ;
if ( mergeStatus === 'automerged' ) {
logger . debug ( 'Branch is automerged - returning' ) ;
return 'automerged' ;
2018-07-09 09:28:33 +00:00
}
if (
2018-07-02 07:33:45 +00:00
mergeStatus === 'automerge aborted - PR exists' ||
mergeStatus === 'branch status error' ||
mergeStatus === 'failed'
) {
logger . info ( { mergeStatus } , 'Branch automerge not possible' ) ;
config . forcePr = true ;
config . branchAutomergeFailureMessage = mergeStatus ;
}
2017-08-26 14:10:18 +00:00
}
2018-03-22 08:26:20 +00:00
} catch ( err ) /* istanbul ignore next */ {
2019-03-16 06:32:36 +00:00
if ( err . statusCode === 404 ) {
throw new Error ( 'repository-changed' ) ;
}
2018-03-22 08:26:20 +00:00
if ( err . message === 'rate-limit-exceeded' ) {
logger . debug ( 'Passing rate-limit-exceeded error up' ) ;
throw err ;
}
2018-02-03 14:45:43 +00:00
if ( err . message === 'repository-changed' ) {
logger . debug ( 'Passing repository-changed error up' ) ;
throw err ;
}
2019-02-13 13:47:37 +00:00
if (
err . message &&
err . message . startsWith ( 'remote: Invalid username or password' )
) {
logger . debug ( 'Throwing bad credentials' ) ;
throw new Error ( 'bad-credentials' ) ;
}
2019-02-13 14:06:51 +00:00
if (
err . message &&
err . message . startsWith (
'ssh_exchange_identification: Connection closed by remote host'
)
) {
logger . debug ( 'Throwing bad credentials' ) ;
throw new Error ( 'bad-credentials' ) ;
}
2018-05-16 05:03:27 +00:00
if ( err . message === 'bad-credentials' ) {
logger . debug ( 'Passing bad-credentials error up' ) ;
throw err ;
}
2018-12-03 11:03:46 +00:00
if ( err . message === 'integration-unauthorized' ) {
logger . debug ( 'Passing integration-unauthorized error up' ) ;
throw err ;
}
2018-05-09 10:10:45 +00:00
if ( err . message === 'lockfile-error' ) {
2018-07-14 05:50:37 +00:00
logger . debug ( 'Passing lockfile-error up' ) ;
2018-05-24 14:28:36 +00:00
throw err ;
}
2019-03-16 06:33:59 +00:00
if ( err . message && err . message . includes ( 'space left on device' ) ) {
2019-02-27 08:01:20 +00:00
throw new Error ( 'disk-space' ) ;
}
2018-09-08 05:16:05 +00:00
if ( err . message . startsWith ( 'disk-space' ) ) {
logger . debug ( 'Passing disk-space error up' ) ;
throw err ;
}
2018-10-30 06:40:09 +00:00
if ( err . message . startsWith ( 'Resource not accessible by integration' ) ) {
logger . debug ( 'Passing 403 error up' ) ;
throw err ;
}
2018-10-09 18:03:37 +00:00
if ( err . message === 'update-failure' ) {
logger . warn ( 'Error updating branch: update failure' ) ;
2019-01-26 14:33:12 +00:00
} else if (
err . message === 'bundler-fs' ||
2019-03-04 03:52:35 +00:00
err . message === 'bundler-credentials' ||
err . message === 'bundler-unknown'
2019-01-26 14:33:12 +00:00
) {
// we have already warned, so just return
return 'error' ;
2019-02-02 01:46:32 +00:00
} else if (
err . messagee &&
err . message . includes ( 'fatal: Authentication failed' )
) {
throw new Error ( 'authentication-failure' ) ;
2018-10-09 18:03:37 +00:00
} else if (
2018-07-21 06:38:13 +00:00
err . message !== 'registry-failure' &&
err . message !== 'platform-failure'
) {
2018-03-21 10:17:54 +00:00
logger . error ( { err } , ` Error updating branch: ${ err . message } ` ) ;
}
2017-08-26 14:47:21 +00:00
// Don't throw here - we don't want to stop the other renovations
2017-08-28 13:50:11 +00:00
return 'error' ;
2017-06-29 17:50:26 +00:00
}
2017-06-22 07:03:36 +00:00
try {
2017-08-26 14:10:18 +00:00
logger . debug ( 'Ensuring PR' ) ;
2017-08-27 11:55:41 +00:00
logger . debug (
2017-11-07 10:52:15 +00:00
` There are ${ config . errors . length } errors and ${
config . warnings . length
} warnings `
2017-08-27 11:55:41 +00:00
) ;
2017-08-26 14:10:18 +00:00
const pr = await prWorker . ensurePr ( config ) ;
// TODO: ensurePr should check for automerge itself
if ( pr ) {
2019-02-08 13:31:30 +00:00
const topic = ':warning: Artifact update problem' ;
if ( config . artifactErrors && config . artifactErrors . length ) {
2017-10-19 12:05:10 +00:00
logger . warn (
2019-02-08 13:31:30 +00:00
{ artifactErrors : config . artifactErrors } ,
'artifactErrors'
2017-10-19 12:05:10 +00:00
) ;
2019-01-06 13:47:42 +00:00
let content = ` ${ appName } failed to update ` ;
2017-10-19 12:05:10 +00:00
content +=
2019-02-08 13:31:30 +00:00
config . artifactErrors . length > 1 ? 'artifacts' : 'an artifact' ;
content +=
' related to this branch. You probably do not want to merge this PR as-is.' ;
content += ` \n \n :recycle: ${ appName } will retry this branch, including artifacts, only when one of the following happens: \n \n ` ;
2017-10-19 12:05:10 +00:00
content +=
2018-10-01 16:15:06 +00:00
' - any of the package files in this branch needs updating, or \n' ;
content += ' - the branch becomes conflicted, or\n' ;
2019-02-08 13:31:30 +00:00
content +=
' - you check the rebase/retry checkbox if found above, or\n' ;
2018-10-01 16:15:06 +00:00
content +=
' - you rename this PR\'s title to start with "rebase!" to trigger it manually' ;
2019-02-08 13:31:30 +00:00
content += '\n\nThe artifact failure details are included below:\n\n' ;
config . artifactErrors . forEach ( error => {
content += ` ##### File name: ${ error . lockFile } \n \n ` ;
2017-11-08 12:26:55 +00:00
content += ` \` \` \` \n ${ error . stderr } \n \` \` \` \n \n ` ;
2017-10-19 12:05:10 +00:00
} ) ;
2019-02-08 13:31:30 +00:00
if (
! (
config . suppressNotifications . includes ( 'artifactErrors' ) ||
config . suppressNotifications . includes ( 'lockFileErrors' )
)
) {
2018-12-08 11:42:56 +00:00
// istanbul ignore if
if ( config . dryRun ) {
logger . info (
'DRY-RUN: Would ensure lock file error comment in PR #' +
pr . number
) ;
} else {
await platform . ensureComment ( pr . number , topic , content ) ;
2019-02-08 13:31:30 +00:00
// TODO: remoe this soon once they're all cleared out
await platform . ensureCommentRemoval (
pr . number ,
':warning: Lock file problem'
) ;
2018-12-08 11:42:56 +00:00
}
2018-10-26 07:48:49 +00:00
}
2019-02-08 13:31:30 +00:00
const context = ` ${ appSlug } /artifacts ` ;
const description = 'Artifact file update failure' ;
2018-07-14 05:50:37 +00:00
const state = 'failure' ;
const existingState = await platform . getBranchStatusCheck (
config . branchName ,
context
) ;
// Check if state needs setting
if ( existingState !== state ) {
logger . debug ( ` Updating status check state to failed ` ) ;
2018-10-26 07:48:49 +00:00
// istanbul ignore if
if ( config . dryRun ) {
logger . info (
'DRY-RUN: Would set branch status in ' + config . branchName
) ;
} else {
await platform . setBranchStatus (
config . branchName ,
context ,
description ,
state
) ;
}
2018-07-14 05:50:37 +00:00
}
2017-10-19 12:05:10 +00:00
} else {
2019-02-08 13:31:30 +00:00
if ( config . updatedArtifacts && config . updatedArtifacts . length ) {
2018-10-26 07:48:49 +00:00
// istanbul ignore if
if ( config . dryRun ) {
logger . info (
'DRY-RUN: Would ensure comment removal in PR #' + pr . number
) ;
} else {
await platform . ensureCommentRemoval ( pr . number , topic ) ;
}
2017-11-16 20:54:13 +00:00
}
2017-10-19 12:05:10 +00:00
const prAutomerged = await prWorker . checkAutoMerge ( pr , config ) ;
if ( prAutomerged ) {
return 'automerged' ;
}
2017-08-28 13:50:11 +00:00
}
2017-06-22 07:03:36 +00:00
}
2018-03-23 06:56:21 +00:00
} catch ( err ) /* istanbul ignore next */ {
2018-12-03 11:04:04 +00:00
if (
[
'rate-limit-exceeded' ,
'platform-failure' ,
'repository-changed' ,
] . includes ( err . message )
) {
2018-07-23 14:47:37 +00:00
logger . debug ( 'Passing PR error up' ) ;
2018-06-19 13:34:37 +00:00
throw err ;
}
2018-03-23 06:56:21 +00:00
// Otherwise don't throw here - we don't want to stop the other renovations
2018-03-27 15:44:05 +00:00
logger . error ( { err } , ` Error ensuring PR: ${ err . message } ` ) ;
2017-06-22 07:03:36 +00:00
}
2018-01-11 10:49:01 +00:00
if ( ! branchExists ) {
return 'pr-created' ;
}
2017-08-28 13:50:11 +00:00
return 'done' ;
2017-06-22 07:03:36 +00:00
}