renovate/lib/workers/repository/process/write.js
2018-10-15 09:21:57 +02:00

44 lines
1.1 KiB
JavaScript

const branchWorker = require('../../branch');
const { getPrsRemaining } = require('./limits');
module.exports = {
writeUpdates,
};
async function writeUpdates(config, packageFiles, allBranches) {
let branches = allBranches;
logger.info(
`Processing ${branches.length} branch${
branches.length !== 1 ? 'es' : ''
}: ${branches
.map(b => b.branchName)
.sort()
.join(', ')}`
);
if (!config.mirrorMode) {
branches = branches.filter(branchConfig => {
if (branchConfig.blockedByPin) {
logger.debug(
`Branch ${branchConfig.branchName} is blocked by a Pin PR`
);
return false;
}
return true;
});
}
let prsRemaining = await getPrsRemaining(config, branches);
for (const branch of branches) {
const res = await branchWorker.processBranch(
branch,
prsRemaining <= 0,
packageFiles
);
branch.res = res;
if (res === 'pr-closed' || res === 'automerged') {
// Stop procesing other branches because base branch has been changed
return res;
}
prsRemaining -= res === 'pr-created' ? 1 : 0;
}
return 'done';
}