mirror of
https://github.com/darksaid98/auto-changelog.git
synced 2026-12-04 14:38:48 +00:00
breaking: Combine similar commit messages into one log line
This commit is contained in:
1 file changed
+22
-7
+22
-7
@@ -12,7 +12,7 @@ export async function generate(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const repoUrl = `https://github.com/${owner}/${repo}`;
|
const repoUrl = `https://github.com/${owner}/${repo}`;
|
||||||
const commits: Commits = {};
|
const commits: Logs = {};
|
||||||
|
|
||||||
paginator: for await (const { data } of octokit.paginate.iterator(
|
paginator: for await (const { data } of octokit.paginate.iterator(
|
||||||
octokit.repos.listCommits,
|
octokit.repos.listCommits,
|
||||||
@@ -44,11 +44,17 @@ export async function generate(
|
|||||||
PR_REGEX,
|
PR_REGEX,
|
||||||
(match, pull) => `[${match}](${repoUrl}/pull/${pull})`,
|
(match, pull) => `[${match}](${repoUrl}/pull/${pull})`,
|
||||||
);
|
);
|
||||||
title = `${title} ([${sha.slice(0, 8)}](${repoUrl}/commit/${sha}))`;
|
|
||||||
|
|
||||||
commits[type] = commits[type] ?? {};
|
commits[type] = commits[type] ?? {};
|
||||||
commits[type][category] = commits[type][category] ?? [];
|
commits[type][category] = commits[type][category] ?? [];
|
||||||
commits[type][category].push(title);
|
|
||||||
|
const existingIndex = commits[type][category].findIndex(
|
||||||
|
(commit) => commit.title === title,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (existingIndex === -1)
|
||||||
|
commits[type][category].push({ title, commits: [sha] });
|
||||||
|
else commits[type][category][existingIndex].commits.push(sha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,8 +78,12 @@ export async function generate(
|
|||||||
|
|
||||||
const baseLine = defaultCategory ? "" : " ";
|
const baseLine = defaultCategory ? "" : " ";
|
||||||
|
|
||||||
for (const title of categoryGroup) {
|
for (const { title, commits } of categoryGroup) {
|
||||||
changelog.push(baseLine + "* " + title);
|
changelog.push(
|
||||||
|
`${baseLine}* ${title} (${commits
|
||||||
|
.map((sha) => `[${sha.slice(0, 8)}](${repoUrl}/commit/${sha})`)
|
||||||
|
.join(",")})`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,8 +119,13 @@ const TYPES = {
|
|||||||
test: "Tests",
|
test: "Tests",
|
||||||
};
|
};
|
||||||
|
|
||||||
interface Commits {
|
interface Logs {
|
||||||
[type: string]: {
|
[type: string]: {
|
||||||
[category: string]: string[];
|
[category: string]: Log[];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Log {
|
||||||
|
title: string;
|
||||||
|
commits: string[];
|
||||||
|
}
|
||||||
Reference in new issue
Block a user