mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
e5654fc812
Helps #777
30 lines
900 B
JavaScript
30 lines
900 B
JavaScript
const handlebars = require('handlebars');
|
|
|
|
module.exports = {
|
|
commitFilesToBranch,
|
|
};
|
|
|
|
async function commitFilesToBranch(config) {
|
|
const { logger } = config;
|
|
const updatedFiles = config.updatedPackageFiles.concat(
|
|
config.updatedLockFiles
|
|
);
|
|
if (updatedFiles.length) {
|
|
logger.debug(`${updatedFiles.length} file(s) to commit`);
|
|
let commitMessage = handlebars.compile(config.commitMessage)(config);
|
|
if (config.semanticCommits) {
|
|
const splitMessage = commitMessage.split('\n');
|
|
splitMessage[0] = splitMessage[0].toLowerCase();
|
|
commitMessage = `${config.semanticPrefix} ${splitMessage.join('\n')}`;
|
|
}
|
|
// API will know whether to create new branch or not
|
|
await config.api.commitFilesToBranch(
|
|
config.branchName,
|
|
updatedFiles,
|
|
commitMessage,
|
|
config.parentBranch
|
|
);
|
|
} else {
|
|
logger.debug(`No files to commit`);
|
|
}
|
|
}
|