Skip to content

Commit

Permalink
feat(changelog): Cleanup commit messages and filter out meta commits
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh committed Dec 25, 2023
1 parent ad3f754 commit 67da582
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
31 changes: 20 additions & 11 deletions src/data/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,33 @@ const changelogRaw = execSync("bash ./scripts/getChangelog.sh")

export interface ChangelogEntry {
ref: string;
link: string;
date: Date;
desc: string;
}

export type Changelog = ChangelogEntry[];

export function getChangelog(): Changelog {
return changelogRaw.flatMap((line) => {
const [ref, date, desc] = line.split("$SEP$");
return changelogRaw
.flatMap((line) => {
const [ref, date, desc] = line.split("$SEP$");

if (!ref || !date || !desc) {
throw new Error("Couldn't parse file info from " + line);
}
if (!ref || !date || !desc) {
throw new Error("Couldn't parse file info from " + line);
}

return {
ref: ref.trim(),
date: new Date(date),
desc: desc.replace("$END$", ""),
};
});
const trimmedRef = ref.trim();
return {
ref: trimmedRef,
link: `https://github.com/Princesseuh/erika.florist/commit/${trimmedRef}`,
date: new Date(date),
desc: cleanChangelogDescription(desc.replace("$END$", "")),
};
})
.filter((entry) => !entry.desc.startsWith("[ci]"));
}

function cleanChangelogDescription(desc: string): string {
return desc.replace("[skip ci]", "").replace("[auto]", "").trim();
}
8 changes: 2 additions & 6 deletions src/pages/changelog.astro
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,8 @@ for (const entry of uniqueMonthYears) {
<ul>
{value.map((changelogEntry) => (
<li>
<a
href={`https://github.com/Princesseuh/erika.florist/commit/${changelogEntry.ref}`}
class="mr-2 font-mono"
>
{changelogEntry.ref}
</a>
{/* prettier-ignore */}
<a href={changelogEntry.link} class="mr-2 font-mono">{changelogEntry.ref}</a>
<span>{changelogEntry.desc}</span>
</li>
))}
Expand Down

0 comments on commit 67da582

Please sign in to comment.