Skip to content

Commit 2a0f270

Browse files
memoize getCommits
1 parent 5d9bb97 commit 2a0f270

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

packages/core/src/__tests__/release.test.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ describe("Release", () => {
10491049
expect(await gh.getSemverBump("1234", "123")).toBe(SEMVER.minor);
10501050
});
10511051

1052-
test("should be able to configure labels", async () => {
1052+
test("should be able to configure labels - no release", async () => {
10531053
const customLabels = [
10541054
...defaultLabels,
10551055
{ name: "Version: Major", releaseType: SEMVER.major },
@@ -1083,7 +1083,30 @@ describe("Release", () => {
10831083
);
10841084

10851085
expect(await gh.getSemverBump("1234", "123")).toBe("");
1086+
});
1087+
1088+
test("should be able to configure labels", async () => {
1089+
const customLabels = [
1090+
...defaultLabels,
1091+
{ name: "Version: Major", releaseType: SEMVER.major },
1092+
{ name: "Version: Minor", releaseType: SEMVER.minor },
1093+
{ name: "Version: Patch", releaseType: SEMVER.patch },
1094+
{ name: "Deploy", releaseType: "release" },
1095+
] as ILabelDefinition[];
1096+
1097+
const gh = new Release(git, {
1098+
onlyPublishWithReleaseLabel: true,
1099+
prereleaseBranches: ["next"],
1100+
labels: customLabels,
1101+
baseBranch: "master",
1102+
});
1103+
const commits = [
1104+
makeCommitFromMsg("First (#1234)"),
1105+
makeCommitFromMsg("Second (#1235)"),
1106+
makeCommitFromMsg("Third (#1236)"),
1107+
];
10861108

1109+
// Test deploy label creates release
10871110
getGitLog.mockReturnValueOnce(commits);
10881111
getPr.mockReturnValueOnce(
10891112
Promise.resolve(mockLabels(["Version: Minor", "Deploy"]))

packages/core/src/git.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ export default class Git {
128128
? this.options.graphqlBaseUrl || join(new URL(this.baseUrl).origin, "api")
129129
: this.baseUrl;
130130
this.logger.veryVerbose.info(`Initializing GitHub with: ${this.baseUrl}`);
131-
const GitHub = Octokit.plugin(enterpriseCompatibility)
132-
.plugin(retry)
133-
.plugin(throttling);
131+
const GitHub = Octokit.plugin(enterpriseCompatibility, retry, throttling);
134132
this.github = new GitHub({
135133
baseUrl: this.baseUrl,
136134
auth: this.options.token,

packages/core/src/release.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ export default class Release {
283283
* @param from - Tag or SHA to start at
284284
* @param to - Tag or SHA to end at (defaults to HEAD)
285285
*/
286+
@memoize()
286287
async getCommits(from: string, to = "HEAD"): Promise<IExtendedCommit[]> {
287288
this.logger.verbose.info(`Getting commits from ${from} to ${to}`);
288289

0 commit comments

Comments
 (0)