fix(worker): fix rebase requested check (#3987)

This commit is contained in:
Michael Kriese 2019-06-30 09:17:16 +02:00 committed by Rhys Arkins
parent 6db4c57aeb
commit 714d4b77f9

View file

@ -39,6 +39,10 @@ async function processBranch(branchConfig, prHourlyLimitReached, packageFiles) {
if (masterIssueCheck) { if (masterIssueCheck) {
logger.info('Branch has been checked in master issue: ' + masterIssueCheck); logger.info('Branch has been checked in master issue: ' + masterIssueCheck);
} }
if (branchPr) {
config.rebaseRequested = rebaseCheck(config, branchPr);
logger.debug(`Branch pr rebase requested: ${config.rebaseRequested}`);
}
try { try {
logger.debug(`Branch has ${dependencies.length} upgrade(s)`); logger.debug(`Branch has ${dependencies.length} upgrade(s)`);
@ -116,19 +120,7 @@ async function processBranch(branchConfig, prHourlyLimitReached, packageFiles) {
} }
if (!branchPr.canRebase) { if (!branchPr.canRebase) {
const subject = 'PR has been edited'; const subject = 'PR has been edited';
const titleRebase = if (masterIssueCheck || config.rebaseRequested) {
branchPr.title && branchPr.title.startsWith('rebase!');
const labelRebase =
branchPr.labels && branchPr.labels.includes(config.rebaseLabel);
const prRebaseChecked =
branchPr.body &&
branchPr.body.includes(`- [x] <!-- ${appSlug}-rebase -->`);
if (
masterIssueCheck ||
prRebaseChecked ||
titleRebase ||
labelRebase
) {
if (config.dryRun) { if (config.dryRun) {
logger.info( logger.info(
'DRY-RUN: Would ensure PR edited comment removal in PR #' + 'DRY-RUN: Would ensure PR edited comment removal in PR #' +
@ -162,11 +154,7 @@ async function processBranch(branchConfig, prHourlyLimitReached, packageFiles) {
logger.info('Skipping branch creation as not within schedule'); logger.info('Skipping branch creation as not within schedule');
return 'not-scheduled'; return 'not-scheduled';
} }
const prRebaseChecked = if (config.updateNotScheduled === false && !config.rebaseRequested) {
branchPr &&
branchPr.body &&
branchPr.body.includes(`- [x] <!-- ${appSlug}-rebase -->`);
if (config.updateNotScheduled === false && !prRebaseChecked) {
logger.debug('Skipping branch update as not within schedule'); logger.debug('Skipping branch update as not within schedule');
return 'not-scheduled'; return 'not-scheduled';
} }
@ -479,3 +467,13 @@ async function processBranch(branchConfig, prHourlyLimitReached, packageFiles) {
} }
return 'done'; return 'done';
} }
function rebaseCheck(config, branchPr) {
const titleRebase = branchPr.title && branchPr.title.startsWith('rebase!');
const labelRebase =
branchPr.labels && branchPr.labels.includes(config.rebaseLabel);
const prRebaseChecked =
branchPr.body && branchPr.body.includes(`- [x] <!-- ${appSlug}-rebase -->`);
return titleRebase || labelRebase || prRebaseChecked;
}