refactor!: optimize changelog references

Signed-off-by: Ardalan Amini <[email protected]>
This commit is contained in:
Ardalan Amini committed 2023-04-30 02:33:42 +03:30
1 parent 7db6dea08c
commit 5c66757e75
3 files changed
+19 -4

No files matched your search

+17 -2
View File
@@ -150,10 +150,25 @@ export async function generateChangelog(lastSha?: string): Promise<string> {
const reference: string[] = [];
if (pr && shouldIncludePRLinks) reference.push(shouldUseGithubAutolink ? `#${ pr }` : `[#${ pr }](${ url }/issues/${ pr })`);
else if (shouldIncludeCommitLinks) reference.push(shouldUseGithubAutolink ? commit.sha : `\`[${ commit.sha }](${ url }/commit/${ commit.sha })\``);
if ((!pr || !shouldIncludePRLinks) && shouldIncludeCommitLinks) reference.push(shouldUseGithubAutolink ? commit.sha : `\`[${ commit.sha }](${ url }/commit/${ commit.sha })\``);
const username = commit.author?.login;
if (commit.author?.login && shouldMentionAuthors) reference.push(`by @${ commit.author.login }`);
if (username && shouldMentionAuthors) {
const mention = `by @${ username }`;
reference.push(mention);
const lastReference = log.references[log.references.length - 1];
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (lastReference?.endsWith(mention)) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
log.references.push(log.references.pop()!.replace(mention, `& ${ reference.join(" ") }`));
continue;
}
}
if (reference.length > 0) log.references.push(reference.join(" "));
}