fix: Changelog containing commits after the current tag (#7)

This commit is contained in:
Ardalan Amini committed 2022-02-20 18:17:51 +03:30
1 parent 8bfda644cc
commit 7cb2e018cf
4 files changed
+28 -14

No files matched your search

+18 -11
View File
@@ -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
View File
@@ -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);