fix: GitHub application author references (#100)

This commit is contained in:
Ardalan Amini authored and GitHub committed 2022-08-14 19:59:43 +04:30
1 parent 632ece8029
commit 758213b4ef
4 files changed
+26 -5

No files matched your search

+20 -3
View File
@@ -1,4 +1,11 @@
import { COMMIT_REGEX, ChangelogInputI, LogsI, ReferenceI } from "./constants";
import {
APP_AUTHOR_SUFFIX,
APP_AUTHOR_SUFFIX_LENGTH,
COMMIT_REGEX,
ChangelogInputI,
LogsI,
ReferenceI,
} from "./constants";
function trim(value: string): string {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
@@ -98,8 +105,18 @@ export async function generate(input: ChangelogInputI): Promise<string> {
changelog.push(`${ baseLine }* ${ title } (${ references
.map(reference => `${
reference.pr == null ? "" : `${ repoUrl }/pull/${ reference.pr } `
}${ repoUrl }/commit/${ reference.commit }${
reference.author == null ? "" : ` by @${ reference.author }`
}${
repoUrl
}/commit/${
reference.commit
}${
reference.author == null
? ""
: (
reference.author.endsWith(APP_AUTHOR_SUFFIX)
? ` by [@${ reference.author }](https://github.com/apps/${ reference.author.slice(0, -APP_AUTHOR_SUFFIX_LENGTH) })`
: ` by @${ reference.author }`
)
}`)
.join(", ") })`);
}
+4
View File
@@ -4,6 +4,10 @@ import { SemVer } from "semver";
export const COMMIT_REGEX
= /^(?<type>[^:()]*)(?:\((?<category>[^()]*?)\)|): *(?<title>.+?) *(?:\(#(?<pr>[1-9]\d*?)\)|) *(?:\[(?<flag>[^[\]]*?)]|)\s*$/;
export const APP_AUTHOR_SUFFIX = "[bot]";
export const APP_AUTHOR_SUFFIX_LENGTH = APP_AUTHOR_SUFFIX.length;
export type TypesI = Record<string, string>;
export type LogsI = Record<string, Record<string, LogI[] | undefined> | undefined>;