parent
9087ef2b62
commit
134146f585
@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
AuthorInfo,
|
||||||
Commit,
|
Commit,
|
||||||
FixUpInfo,
|
FixUpInfo,
|
||||||
InputReleaseType,
|
InputReleaseType,
|
||||||
@ -30,6 +31,9 @@ export default class ChangelogData {
|
|||||||
// Map of project IDs to info text and/or details
|
// Map of project IDs to info text and/or details
|
||||||
modInfoList: Map<number, ParsedModInfo>;
|
modInfoList: Map<number, ParsedModInfo>;
|
||||||
|
|
||||||
|
// Map of commit sha to specified coauthors for that commit
|
||||||
|
coAuthorList: Map<string, AuthorInfo[]>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Non-Async Inits are performed here.
|
* Constructor. Non-Async Inits are performed here.
|
||||||
*/
|
*/
|
||||||
@ -70,6 +74,7 @@ export default class ChangelogData {
|
|||||||
this.combineList = new Map<string, Commit[]>();
|
this.combineList = new Map<string, Commit[]>();
|
||||||
|
|
||||||
this.modInfoList = new Map<number, ParsedModInfo>();
|
this.modInfoList = new Map<number, ParsedModInfo>();
|
||||||
|
this.coAuthorList = new Map<string, AuthorInfo[]>();
|
||||||
|
|
||||||
// Init Tag Sets for Now, so we don't have to deal with nullable params
|
// Init Tag Sets for Now, so we don't have to deal with nullable params
|
||||||
this.tags = new Set<string>();
|
this.tags = new Set<string>();
|
||||||
@ -116,6 +121,7 @@ export default class ChangelogData {
|
|||||||
this.combineList = new Map<string, Commit[]>();
|
this.combineList = new Map<string, Commit[]>();
|
||||||
|
|
||||||
this.modInfoList = new Map<number, ParsedModInfo>();
|
this.modInfoList = new Map<number, ParsedModInfo>();
|
||||||
|
this.coAuthorList = new Map<string, AuthorInfo[]>();
|
||||||
|
|
||||||
// Tags list is fine because the 'to' (Target) stays the same
|
// Tags list is fine because the 'to' (Target) stays the same
|
||||||
// Other Tags list is generated at setup
|
// Other Tags list is generated at setup
|
||||||
|
@ -41,6 +41,8 @@ export const ignoreKey = "[IGNORE]";
|
|||||||
export const modInfoKey = "[MOD INFO]";
|
export const modInfoKey = "[MOD INFO]";
|
||||||
export const modInfoList = "infos";
|
export const modInfoList = "infos";
|
||||||
export const priorityKey = "[PRIORITY]";
|
export const priorityKey = "[PRIORITY]";
|
||||||
|
export const coAuthorsKey = "[AUTHORS]";
|
||||||
|
export const coAuthorsList = "authors";
|
||||||
|
|
||||||
/* Sub Category Keys */
|
/* Sub Category Keys */
|
||||||
// Mode Category Keys
|
// Mode Category Keys
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
} from "#types/changelogTypes.ts";
|
} from "#types/changelogTypes.ts";
|
||||||
import {
|
import {
|
||||||
categories,
|
categories,
|
||||||
|
coAuthorsKey,
|
||||||
combineKey,
|
combineKey,
|
||||||
defaultIndentation,
|
defaultIndentation,
|
||||||
detailsKey,
|
detailsKey,
|
||||||
@ -18,6 +19,7 @@ import {
|
|||||||
priorityKey,
|
priorityKey,
|
||||||
} from "./definitions.ts";
|
} from "./definitions.ts";
|
||||||
import {
|
import {
|
||||||
|
parseCoAuthor,
|
||||||
parseCombine,
|
parseCombine,
|
||||||
parseDetails,
|
parseDetails,
|
||||||
parseExpand,
|
parseExpand,
|
||||||
@ -111,6 +113,9 @@ export async function parseCommitBody(
|
|||||||
if (commitBody.includes(modInfoKey))
|
if (commitBody.includes(modInfoKey))
|
||||||
await parseModInfo(commitBody, commitObject);
|
await parseModInfo(commitBody, commitObject);
|
||||||
|
|
||||||
|
if (commitBody.includes(coAuthorsKey))
|
||||||
|
await parseCoAuthor(commitBody, commitObject);
|
||||||
|
|
||||||
if (commitBody.includes(expandKey)) {
|
if (commitBody.includes(expandKey)) {
|
||||||
await parseExpand(commitBody, commitObject, parser);
|
await parseExpand(commitBody, commitObject, parser);
|
||||||
return true;
|
return true;
|
||||||
|
@ -287,43 +287,57 @@ export async function formatMessage(
|
|||||||
return `${indentation}* ${message} - ${author} (${formattedCommit})`;
|
return `${indentation}* ${message} - ${author} (${formattedCommit})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort original array so newest commits appear at the end instead of start of commit string
|
|
||||||
sortCommitListReverse(commits);
|
|
||||||
|
|
||||||
const formattedCommits: string[] = [];
|
const formattedCommits: string[] = [];
|
||||||
const authors: string[] = [];
|
const authors: string[] = [];
|
||||||
const retrievedAuthors: { commit: Commit; formatted: string }[] =
|
const retrievedAuthors: { commit: Commit; name: string; email: string }[] =
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
commits.map((commit) =>
|
commits.map((commit) =>
|
||||||
formatAuthor(commit).then((formatted) => {
|
formatAuthor(commit).then((name) => {
|
||||||
return { commit, formatted };
|
return { commit, name, email: commit.author_email };
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const processedSHAs: Set<string> = new Set<string>();
|
||||||
|
|
||||||
|
sortCommitList(commits, (commit) => commit);
|
||||||
|
|
||||||
|
// Co-Authors for Each Commit, Format Commits
|
||||||
|
commits.forEach((commit) => {
|
||||||
|
if (processedSHAs.has(commit.hash)) return;
|
||||||
|
formattedCommits.push(
|
||||||
|
`[\`${commit.hash.substring(0, 7)}\`](${repoLink}commit/${commit.hash})`,
|
||||||
|
);
|
||||||
|
processedSHAs.add(commit.hash);
|
||||||
|
|
||||||
|
const authors = data.coAuthorList.get(commit.hash);
|
||||||
|
if (!authors || authors.length === 0) return;
|
||||||
|
|
||||||
|
retrievedAuthors.push(
|
||||||
|
...authors.map((author) => {
|
||||||
|
return { commit, name: `@${author.name}`, email: author.email };
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
const processedAuthors: Set<string> = new Set<string>();
|
const processedAuthors: Set<string> = new Set<string>();
|
||||||
const processedEmails: Set<string> = new Set<string>();
|
const processedEmails: Set<string> = new Set<string>();
|
||||||
const processedSHAs: Set<string> = new Set<string>();
|
|
||||||
|
|
||||||
sortCommitList(
|
sortCommitList(
|
||||||
retrievedAuthors,
|
retrievedAuthors,
|
||||||
(author) => author.commit,
|
(author) => author.commit,
|
||||||
(a, b) => a.formatted.localeCompare(b.formatted),
|
(a, b) => a.name.localeCompare(b.name),
|
||||||
);
|
);
|
||||||
retrievedAuthors.forEach((pAuthor) => {
|
retrievedAuthors.forEach((pAuthor) => {
|
||||||
if (processedSHAs.has(pAuthor.commit.hash)) return;
|
// Author
|
||||||
if (
|
if (
|
||||||
!processedAuthors.has(pAuthor.formatted) &&
|
!processedAuthors.has(pAuthor.name) &&
|
||||||
!processedEmails.has(pAuthor.commit.author_email)
|
!processedEmails.has(pAuthor.email)
|
||||||
) {
|
) {
|
||||||
authors.push(pAuthor.formatted);
|
authors.push(pAuthor.name);
|
||||||
processedAuthors.add(pAuthor.formatted);
|
processedAuthors.add(pAuthor.name);
|
||||||
processedEmails.add(pAuthor.commit.author_email);
|
processedEmails.add(pAuthor.email);
|
||||||
}
|
}
|
||||||
formattedCommits.push(
|
|
||||||
`[\`${pAuthor.commit.hash.substring(0, 7)}\`](${repoLink}commit/${pAuthor.commit.hash})`,
|
|
||||||
);
|
|
||||||
processedSHAs.add(pAuthor.commit.hash);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Delete all Formatted Commits after MaxIncludeCommits elements, replace with '...'
|
// Delete all Formatted Commits after MaxIncludeCommits elements, replace with '...'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
AuthorInfo,
|
||||||
ChangelogMessage,
|
ChangelogMessage,
|
||||||
Commit,
|
Commit,
|
||||||
ExpandedMessage,
|
ExpandedMessage,
|
||||||
@ -14,6 +15,8 @@ import {
|
|||||||
import dedent from "dedent-js";
|
import dedent from "dedent-js";
|
||||||
import matter, { GrayMatterFile } from "gray-matter";
|
import matter, { GrayMatterFile } from "gray-matter";
|
||||||
import {
|
import {
|
||||||
|
coAuthorsKey,
|
||||||
|
coAuthorsList,
|
||||||
combineKey,
|
combineKey,
|
||||||
combineList,
|
combineList,
|
||||||
combineRoot,
|
combineRoot,
|
||||||
@ -165,6 +168,29 @@ export async function parseIgnore(
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a commit with coauthor info.
|
||||||
|
*/
|
||||||
|
export async function parseCoAuthor(
|
||||||
|
commitBody: string,
|
||||||
|
commitObject: Commit,
|
||||||
|
): Promise<void> {
|
||||||
|
if (!commitBody.includes(coAuthorsKey)) return;
|
||||||
|
await parseTOMLWithRootToList<AuthorInfo>(
|
||||||
|
commitBody,
|
||||||
|
commitObject,
|
||||||
|
coAuthorsKey,
|
||||||
|
coAuthorsList,
|
||||||
|
(item) => !item.email || !item.name,
|
||||||
|
async (item) => {
|
||||||
|
const authors = data.coAuthorList.get(commitObject.hash) ?? [];
|
||||||
|
authors.push(item);
|
||||||
|
data.coAuthorList.set(commitObject.hash, authors);
|
||||||
|
},
|
||||||
|
(item) => item as unknown as AuthorInfo,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a commit with 'Fixup'.
|
* Parses a commit with 'Fixup'.
|
||||||
*/
|
*/
|
||||||
|
@ -301,6 +301,11 @@ export interface PriorityInfo {
|
|||||||
priority: number;
|
priority: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface AuthorInfo {
|
||||||
|
name: string;
|
||||||
|
email: string;
|
||||||
|
}
|
||||||
|
|
||||||
export type FixUpMode = "REPLACE" | "ADDITION";
|
export type FixUpMode = "REPLACE" | "ADDITION";
|
||||||
|
|
||||||
export type InputReleaseType =
|
export type InputReleaseType =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user