Skip to content
Snippets Groups Projects
Commit 976f2ac5 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

feat: deduplicate changelogs

Deduplicate changelogs in monorepo PRs. i.e. the same monorepo won’t be included more than once.
parent e0e0b9de
No related branches found
No related tags found
No related merge requests found
...@@ -70,6 +70,8 @@ async function ensurePr(prConfig) { ...@@ -70,6 +70,8 @@ async function ensurePr(prConfig) {
const issueRe = /([\s(])#(\d+)([)\s]?)/g; const issueRe = /([\s(])#(\d+)([)\s]?)/g;
const commitRepos = [];
// Get changelog and then generate template strings // Get changelog and then generate template strings
for (const upgrade of upgrades) { for (const upgrade of upgrades) {
const upgradeKey = `${upgrade.depName}-${upgrade.changeLogFromVersion}-${ const upgradeKey = `${upgrade.depName}-${upgrade.changeLogFromVersion}-${
...@@ -85,33 +87,35 @@ async function ensurePr(prConfig) { ...@@ -85,33 +87,35 @@ async function ensurePr(prConfig) {
upgrade.changeLogFromVersion, upgrade.changeLogFromVersion,
upgrade.changeLogToVersion upgrade.changeLogToVersion
); );
// Store changelog markdown for backwards compatibility
if (logJSON) { if (logJSON) {
upgrade.githubName = logJSON.project.github; upgrade.githubName = logJSON.project.github;
upgrade.releases = []; upgrade.releases = [];
logJSON.versions.forEach(version => { if (!commitRepos.includes(upgrade.githubName)) {
const release = { ...version }; commitRepos.push(upgrade.githubName);
release.commits = []; logJSON.versions.forEach(version => {
if (release.changes) { const release = { ...version };
release.changes.forEach(change => { release.commits = [];
const commit = { ...change }; if (release.changes) {
delete commit.date; release.changes.forEach(change => {
commit.shortSha = change.sha.slice(0, 7); const commit = { ...change };
commit.url = `${logJSON.project.repository}/commit/${change.sha}`; delete commit.date;
if (change.message) { commit.shortSha = change.sha.slice(0, 7);
[commit.message] = change.message.split('\n'); commit.url = `${logJSON.project.repository}/commit/${change.sha}`;
if (!config.isGitHub || config.privateRepo === true) { if (change.message) {
commit.message = commit.message.replace( [commit.message] = change.message.split('\n');
issueRe, if (!config.isGitHub || config.privateRepo === true) {
`$1[#$2](${upgrade.repositoryUrl}/issues/$2)$3` commit.message = commit.message.replace(
); issueRe,
`$1[#$2](${upgrade.repositoryUrl}/issues/$2)$3`
);
}
} }
} release.commits.push(commit);
release.commits.push(commit); });
}); }
} upgrade.releases.push(release);
upgrade.releases.push(release); });
}); }
} }
config.upgrades.push(upgrade); config.upgrades.push(upgrade);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment