mirror of
https://github.com/darksaid98/auto-changelog.git
synced 2026-12-04 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(", ")})`,
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user