mirror of
https://github.com/darksaid98/auto-changelog.git
synced 2026-12-02 22:16:06 +00:00
feat: add include-commit-links & include-pr-links action inputs (#136)
This commit is contained in:
1 parent
59a206c296
commit
479475eda0
7 files changed
+39042
-25
No files matched your search
+26
-20
@@ -20,7 +20,7 @@ function unique(value: string[]): string[] {
|
||||
|
||||
export async function generate(input: ChangelogInputI): Promise<string> {
|
||||
const { octokit, owner, repo, sha, tagRef, inputs } = input;
|
||||
const { commitTypes, defaultCommitType, mentionAuthors } = inputs;
|
||||
const { commitTypes, defaultCommitType, mentionAuthors, includePRLinks, includeCommitLinks } = inputs;
|
||||
|
||||
const repoUrl = `https://github.com/${ owner }/${ repo }`;
|
||||
const commits: LogsI = {};
|
||||
@@ -66,8 +66,8 @@ export async function generate(input: ChangelogInputI): Promise<string> {
|
||||
|
||||
const reference: ReferenceI = {
|
||||
author: mentionAuthors ? commit.author?.login : null,
|
||||
commit: commit.sha,
|
||||
pr,
|
||||
commit: includeCommitLinks ? commit.sha : null,
|
||||
pr : includePRLinks ? pr : null,
|
||||
};
|
||||
|
||||
if (existingCommit == null) {
|
||||
@@ -102,23 +102,29 @@ export async function generate(input: ChangelogInputI): Promise<string> {
|
||||
const baseLine = defaultCategory ? "" : " ";
|
||||
|
||||
for (const { title, references } of categoryGroup) {
|
||||
changelog.push(`${ baseLine }* ${ title } (${ references
|
||||
.map(reference => `${
|
||||
reference.pr == null ? "" : `${ repoUrl }/pull/${ reference.pr } `
|
||||
}${
|
||||
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(", ") })`);
|
||||
let log = `${ baseLine }* ${ title }`;
|
||||
|
||||
const links: string[] = [];
|
||||
|
||||
for (const { pr, commit, author } of references) {
|
||||
const link: string[] = [];
|
||||
|
||||
if (pr != null) link.push(`${ repoUrl }/pull/${ pr }`);
|
||||
|
||||
if (commit != null) link.push(`${ repoUrl }/commit/${ commit }`);
|
||||
|
||||
if (author != null) {
|
||||
// eslint-disable-next-line max-depth
|
||||
if (author.endsWith(APP_AUTHOR_SUFFIX)) link.push(`by [@${ author }](https://github.com/apps/${ author.slice(0, -APP_AUTHOR_SUFFIX_LENGTH) })`);
|
||||
else link.push(`by @${ author }`);
|
||||
}
|
||||
|
||||
if (link.length > 0) links.push(link.join(" "));
|
||||
}
|
||||
|
||||
if (links.length > 0) log += ` (${ links.join(", ") })`;
|
||||
|
||||
changelog.push(log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -19,8 +19,8 @@ export interface LogI {
|
||||
|
||||
export interface ReferenceI {
|
||||
author?: string | null;
|
||||
commit: string;
|
||||
pr?: string;
|
||||
commit: string | null;
|
||||
pr?: string | null;
|
||||
}
|
||||
|
||||
export interface TagInputI {
|
||||
@@ -49,7 +49,9 @@ export interface ChangelogInputI {
|
||||
export interface ActionInputsI {
|
||||
commitTypes: TypesI;
|
||||
defaultCommitType: string;
|
||||
includeCommitLinks: boolean;
|
||||
includeCompare: boolean;
|
||||
includePRLinks: boolean;
|
||||
mentionAuthors: boolean;
|
||||
mentionNewContributors: boolean;
|
||||
releaseName: string;
|
||||
|
||||
@@ -16,6 +16,8 @@ export async function getInputs(): Promise<ActionInputsI> {
|
||||
required: true,
|
||||
});
|
||||
const includeCompare = getBooleanInput("include-compare", { required: true });
|
||||
const includePRLinks = getBooleanInput("include-pr-links", { required: true });
|
||||
const includeCommitLinks = getBooleanInput("include-commit-links", { required: true });
|
||||
const semver = getBooleanInput("semver", { required: true });
|
||||
|
||||
return Joi.object<ActionInputsI, true>()
|
||||
@@ -28,6 +30,8 @@ export async function getInputs(): Promise<ActionInputsI> {
|
||||
mentionAuthors : Joi.boolean().required(),
|
||||
mentionNewContributors: Joi.boolean().required(),
|
||||
includeCompare : Joi.boolean().required(),
|
||||
includePRLinks : Joi.boolean().required(),
|
||||
includeCommitLinks : Joi.boolean().required(),
|
||||
semver : Joi.boolean().required(),
|
||||
})
|
||||
.validateAsync({
|
||||
@@ -37,6 +41,8 @@ export async function getInputs(): Promise<ActionInputsI> {
|
||||
mentionAuthors,
|
||||
mentionNewContributors,
|
||||
includeCompare,
|
||||
includePRLinks,
|
||||
includeCommitLinks,
|
||||
semver,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user