mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 21:07:46 +00:00
* refactor and add test to changelog * group changelog into areas * remove revert and reverted commits from changelog * make sure Revert commits that revert a commit in a previous changelog are not filtered * run "yarn test" as part of "yarn test-unit" * remove advanced syntax * remove advanced syntax * temp changelog * remove temp changelog * remove global jest config * Delete symlink * scope jest dir to just the test files we care about
32 lines
854 B
JavaScript
32 lines
854 B
JavaScript
/**
|
|
* Filters out "Revert" commits as well as the commits they revert, if found.
|
|
*/
|
|
function filterReverts(commits) {
|
|
const revertCommits = commits.filter(commit => commit.revertsHashes.length);
|
|
const commitHashes = commits.map(commit => commit.hash);
|
|
|
|
let hashesToRemove = [];
|
|
revertCommits.forEach(revertCommit => {
|
|
const allFound = revertCommit.revertsHashes.every(hash => {
|
|
return commitHashes.includes(hash);
|
|
});
|
|
|
|
if (allFound) {
|
|
hashesToRemove = [
|
|
...hashesToRemove,
|
|
...revertCommit.revertsHashes,
|
|
revertCommit.hash,
|
|
];
|
|
}
|
|
});
|
|
|
|
return commits.filter(commit => !hashesToRemove.includes(commit.hash));
|
|
}
|
|
|
|
function normalizeLog(commits) {
|
|
commits = commits.filter(line => !line.subject.startsWith('Publish '));
|
|
return filterReverts(commits);
|
|
}
|
|
|
|
module.exports = normalizeLog;
|