mirror of
https://github.com/darksaid98/auto-changelog.git
synced 2026-12-03 06:28:52 +00:00
feat: Add ability to mention the commit authors (#52)
* feat: Add mention-authors input * feat: Add ability to mention the commit authors
This commit is contained in:
1 parent
fb0a5b1b30
commit
979eade40d
8 files changed
+42
-9
No files matched your search
+13
-6
@@ -1,8 +1,8 @@
|
||||
import { ChangelogInputI, COMMIT_REGEX, LogsI } from "./constants";
|
||||
import { ChangelogInputI, COMMIT_REGEX, LogsI, ReferenceI } from "./constants";
|
||||
|
||||
export async function generate(input: ChangelogInputI): Promise<string> {
|
||||
const { octokit, owner, repo, sha, tagRef, inputs } = input;
|
||||
const { commitTypes, defaultCommitType } = inputs;
|
||||
const { commitTypes, defaultCommitType, mentionAuthors } = inputs;
|
||||
|
||||
const repoUrl = `https://github.com/${owner}/${repo}`;
|
||||
const commits: LogsI = {};
|
||||
@@ -45,9 +45,14 @@ export async function generate(input: ChangelogInputI): Promise<string> {
|
||||
|
||||
const existingCommit = logs.find((commit) => commit.title === title);
|
||||
|
||||
if (existingCommit == null) {
|
||||
logs.push({ title, references: [{ commit: commit.sha, pr }] });
|
||||
} else existingCommit.references.push({ commit: commit.sha, pr });
|
||||
const reference: ReferenceI = {
|
||||
author: mentionAuthors ? commit.author?.login : undefined,
|
||||
commit: commit.sha,
|
||||
pr,
|
||||
};
|
||||
|
||||
if (existingCommit == null) logs.push({ title, references: [reference] });
|
||||
else existingCommit.references.push(reference);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +82,9 @@ export async function generate(input: ChangelogInputI): Promise<string> {
|
||||
(reference) =>
|
||||
`${
|
||||
reference.pr == null ? "" : `${repoUrl}/pull/${reference.pr} `
|
||||
}${repoUrl}/commit/${reference.commit}`,
|
||||
}${repoUrl}/commit/${reference.commit}${
|
||||
reference.author == null ? "" : ` by @${reference.author}`
|
||||
}`,
|
||||
)
|
||||
.join(", ")})`,
|
||||
);
|
||||
|
||||
@@ -20,6 +20,7 @@ export interface LogI {
|
||||
}
|
||||
|
||||
export interface ReferenceI {
|
||||
author?: string;
|
||||
commit: string;
|
||||
pr?: string;
|
||||
}
|
||||
@@ -51,6 +52,7 @@ export interface ActionInputsI {
|
||||
commitTypes: TypesI;
|
||||
defaultCommitType: string;
|
||||
releaseName: string;
|
||||
mentionAuthors: boolean;
|
||||
mentionNewContributors: boolean;
|
||||
includeCompare: boolean;
|
||||
semver: boolean;
|
||||
|
||||
@@ -11,6 +11,7 @@ export async function getInputs(): Promise<ActionInputsI> {
|
||||
const commitTypes = YAML.parse(getInput("commit-types", { required: true }));
|
||||
const defaultCommitType = getInput("default-commit-type", { required: true });
|
||||
const releaseName = getInput("release-name", { required: true });
|
||||
const mentionAuthors = getBooleanInput("mention-authors", { required: true });
|
||||
const mentionNewContributors = getBooleanInput("mention-new-contributors", {
|
||||
required: true,
|
||||
});
|
||||
@@ -24,6 +25,7 @@ export async function getInputs(): Promise<ActionInputsI> {
|
||||
.required(),
|
||||
defaultCommitType: Joi.string().required(),
|
||||
releaseName: Joi.string().required(),
|
||||
mentionAuthors: Joi.boolean().required(),
|
||||
mentionNewContributors: Joi.boolean().required(),
|
||||
includeCompare: Joi.boolean().required(),
|
||||
semver: Joi.boolean().required(),
|
||||
@@ -32,6 +34,7 @@ export async function getInputs(): Promise<ActionInputsI> {
|
||||
commitTypes,
|
||||
defaultCommitType,
|
||||
releaseName,
|
||||
mentionAuthors,
|
||||
mentionNewContributors,
|
||||
includeCompare,
|
||||
semver,
|
||||
|
||||
Reference in new issue
Block a user