mirror of
https://github.com/darksaid98/auto-changelog.git
synced 2026-12-02 06:28:53 +00:00
fix: Changelog containing commits after the current tag (#7)
This commit is contained in:
4 files changed
+28
-14
No files matched your search
+18
-11
@@ -1,18 +1,15 @@
|
||||
import type { GitHub } from "@actions/github/lib/utils";
|
||||
|
||||
export async function generate(
|
||||
octokit: InstanceType<typeof GitHub>,
|
||||
exclude: string[],
|
||||
owner: string,
|
||||
repo: string,
|
||||
tagRef?: string,
|
||||
): Promise<string> {
|
||||
export async function generate(input: InputI): Promise<string> {
|
||||
const { octokit, owner, repo, sha, tagRef } = input;
|
||||
let { exclude } = input;
|
||||
|
||||
exclude = exclude.map(
|
||||
(type) => (TYPES as { [type: string]: string | undefined })[type] ?? type,
|
||||
);
|
||||
|
||||
const repoUrl = `https://github.com/${owner}/${repo}`;
|
||||
const commits: Logs = {};
|
||||
const commits: LogsI = {};
|
||||
|
||||
paginator: for await (const { data } of octokit.paginate.iterator(
|
||||
octokit.rest.repos.listCommits,
|
||||
@@ -20,6 +17,7 @@ export async function generate(
|
||||
per_page: 100,
|
||||
owner,
|
||||
repo,
|
||||
sha,
|
||||
},
|
||||
)) {
|
||||
for (const { sha, ...commit } of data) {
|
||||
@@ -120,13 +118,22 @@ const TYPES = {
|
||||
test: "Tests",
|
||||
};
|
||||
|
||||
interface Logs {
|
||||
interface LogsI {
|
||||
[type: string]: {
|
||||
[category: string]: Log[];
|
||||
[category: string]: LogI[];
|
||||
};
|
||||
}
|
||||
|
||||
interface Log {
|
||||
interface LogI {
|
||||
title: string;
|
||||
commits: string[];
|
||||
}
|
||||
|
||||
export interface InputI {
|
||||
octokit: InstanceType<typeof GitHub>;
|
||||
exclude: string[];
|
||||
owner: string;
|
||||
repo: string;
|
||||
sha: string;
|
||||
tagRef?: string;
|
||||
}
|
||||
+8
-1
@@ -25,7 +25,14 @@ async function run() {
|
||||
} else tagRef = tags[0].commit.sha;
|
||||
}
|
||||
|
||||
const changelog = await generate(octokit, exclude, owner, repo, tagRef);
|
||||
const changelog = await generate({
|
||||
octokit,
|
||||
exclude,
|
||||
owner,
|
||||
repo,
|
||||
sha,
|
||||
tagRef,
|
||||
});
|
||||
|
||||
info(changelog);
|
||||
|
||||
|
||||
Reference in new issue
Block a user