Changelog Improvements (#466)

- [Add time zone to cutting edge changelog](d29e9a9b33)

- [Make Multi Commits appear in reverse (oldest -> newest)](4469ace03c)

[COMBINE]
commits = ["fbd1584e7baed4a3603e3c810066603185f1b230"]
[COMBINE]

[FIXUP]
[[fixes]]
sha = "2a0f5eab525c7f9b29ace0c003c95ef44160af05"
newTitle = "Fix Workflows Pushing to Main (#465)"
newBody = """
[COMBINE]
commits = [\"fbd1584e7baed4a3603e3c810066603185f1b230\"]
[COMBINE]
"""

[[fixes]]
sha = "e2aac147e539f48b01e702a24fba8e6fa6666861"
newTitle = "Fix Non Release Commit Workflow (#464)"
newBody = """
[COMBINE]
commits = [\"fbd1584e7baed4a3603e3c810066603185f1b230\"]
[COMBINE]
"""

[[fixes]]
sha = "7a6a147006dbc6fca439e6fc4c1bff8f3d4e1c9d"
newTitle = "Fix Parsing Complex Bodies in GitHub Commits (#460)"
newBody = """
[COMBINE]
commits = [\"fbd1584e7baed4a3603e3c810066603185f1b230\"]
[COMBINE]
"""
[FIXUP]
This commit is contained in:
IntegerLimit 2023-10-21 13:36:14 +11:00 committed by GitHub
parent cd3e175876
commit ce5272fcf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import mustache from "mustache";
import { defaultIndentation, modChangesAllocations, repoLink } from "./definitions";
import ChangelogData from "./changelogData";
import { SpecialChangelogFormatting } from "../../types/changelogTypes";
import { sortCommitListReverse } from "./pusher";
/**
* Mod Changes special formatting
@ -83,6 +84,9 @@ export default async function generateModChanges(data: ChangelogData): Promise<v
let commits: Commit[] = undefined;
if (info.projectID && projectIDsToCommits.has(info.projectID)) {
commits = projectIDsToCommits.get(info.projectID);
// Sort array so newest commits appear at end instead of start of commit string
sortCommitListReverse(commits);
}
block.allocation.category.changelogSection.get(block.allocation.subCategory).push({
commitMessage: getModChangeMessage(info, block.allocation.template),

View File

@ -18,14 +18,15 @@ export default function pushAll(inputData: ChangelogData): void {
hour12: true,
hour: "numeric",
minute: "numeric",
timeZoneName: "short",
});
// noinspection HtmlUnknownAttribute
data.builder.push(`<h1 {{{ CENTER_ALIGN }}}>${data.releaseType} (${date})</h1>`, "");
// noinspection HtmlDeprecatedAttribute
data.builder.push(`<h1 align="center">${data.releaseType} (${date})</h1>`, "");
} else {
// noinspection HtmlUnknownAttribute
data.builder.push(`<h1 {{{ CENTER_ALIGN }}}>${data.releaseType} ${data.to}</h1>`, "");
data.builder.push("{{{ CF_REDIRECT }}}", "");
}
data.builder.push("{{{ CF_REDIRECT }}}", "");
data.builder.push(`# Changes Since ${data.since}`, "");
// Push Sections of Changelog
@ -107,7 +108,7 @@ function pushCategory(category: Category) {
* Sorts a list that contains commit data
* @param list A list of type T that contains commit data
* @param transform A function to turn each element of type T into an element of type Commit
* @param backup A backup sort, to call when either element does not have a commit object, or when the commit objects' times are the same. Optional, if not set, will just return 0 (equal).
* @param backup A backup sort, to call when either element does not have a commit object, or when the commit objects' times are the same. Optional, if not set, will just return 0 (equal) or will compare commit messages.
*/
function sortCommitList<T>(list: T[], transform: (obj: T) => Commit | undefined, backup?: (a: T, b: T) => number) {
list.sort((a, b): number => {
@ -128,6 +129,20 @@ function sortCommitList<T>(list: T[], transform: (obj: T) => Commit | undefined,
});
}
/**
* Sorts a commits list so that newest commits are on the bottom.
* @param list The commit list.
*/
export function sortCommitListReverse(list: Commit[]) {
list.sort((a, b) => {
const dateA = new Date(a.date);
const dateB = new Date(b.date);
if (dateB.getTime() - dateA.getTime() !== 0) return dateA.getTime() - dateB.getTime();
return a.message.localeCompare(b.message);
});
}
/**
* Formats a Changelog Message
* @param changelogMessage The message to format.
@ -154,7 +169,10 @@ function formatChangelogMessage(changelogMessage: ChangelogMessage, subMessage =
if (changelogMessage.commitObject && !subMessage) {
if (data.combineList.has(changelogMessage.commitObject.hash)) {
const commits = data.combineList.get(changelogMessage.commitObject.hash);
commits.unshift(changelogMessage.commitObject);
commits.push(changelogMessage.commitObject);
// Sort original array so newest commits appear at the end instead of start of commit string
sortCommitListReverse(commits);
const formattedCommits: string[] = [];
const authors: string[] = [];