From 7eb8ef84c82f2a1a46a87382498eea0e20564656 Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Sun, 20 Mar 2022 17:20:40 -0700 Subject: [PATCH] create major version at last release tag --- .../src/__tests__/major-version-branches.test.ts | 10 ++++++++-- packages/core/src/auto.ts | 12 +++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/core/src/__tests__/major-version-branches.test.ts b/packages/core/src/__tests__/major-version-branches.test.ts index 3bc8f9c54..551d54599 100644 --- a/packages/core/src/__tests__/major-version-branches.test.ts +++ b/packages/core/src/__tests__/major-version-branches.test.ts @@ -70,9 +70,14 @@ describe("Old Version Branches", () => { auto.hooks.getPreviousVersion.tap("test", () => "1.0.0"); await auto.hooks.beforeCommitChangelog.promise({ bump: SEMVER.major, + lastRelease: "1.0.0", } as any); - expect(execSpy).toHaveBeenCalledWith("git", ["branch", "version-1"]); + expect(execSpy).toHaveBeenCalledWith("git", [ + "branch", + "version-1", + "1.0.0", + ]); }); test("should be able to customize old version branches", async () => { @@ -85,8 +90,9 @@ describe("Old Version Branches", () => { auto.hooks.getPreviousVersion.tap("test", () => "1.0.0"); await auto.hooks.beforeCommitChangelog.promise({ bump: SEMVER.major, + lastRelease: "1.0.0", } as any); - expect(execSpy).toHaveBeenCalledWith("git", ["branch", "v1"]); + expect(execSpy).toHaveBeenCalledWith("git", ["branch", "v1", "1.0.0"]); }); }); diff --git a/packages/core/src/auto.ts b/packages/core/src/auto.ts index 8775faf1f..68d0973ea 100644 --- a/packages/core/src/auto.ts +++ b/packages/core/src/auto.ts @@ -459,13 +459,13 @@ export default class Auto { }); this.hooks.beforeCommitChangelog.tapPromise( "Old Version Branches", - async ({ bump }) => { + async ({ bump, lastRelease }) => { if (bump === SEMVER.major && this.config?.versionBranches) { const branch = `${this.config.versionBranches}${major( await this.hooks.getPreviousVersion.promise() )}`; - await execPromise("git", ["branch", branch]); + await execPromise("git", ["branch", branch, lastRelease]); this.logger.log.success(`Created old version branch: ${branch}`); await execPromise("git", ["push", this.remote, branch]); } @@ -1343,7 +1343,7 @@ export default class Auto { } } - const verb = options.dryRun ? "Would have published" : "Published" + const verb = options.dryRun ? "Would have published" : "Published"; this.logger.log.success( `${verb} canary version${newVersion ? `: ${newVersion}` : ""}` ); @@ -1715,7 +1715,9 @@ export default class Auto { const bump = await this.getVersion(options); - this.logger.log.success(`Calculated version bump: ${options.useVersion || bump || "none"}`); + this.logger.log.success( + `Calculated version bump: ${options.useVersion || bump || "none"}` + ); if (bump === "" && !options.useVersion) { this.logger.log.info("No version published."); @@ -1751,7 +1753,7 @@ export default class Auto { this.logger.verbose.info("Calling publish hook"); await this.hooks.publish.promise({ bump, - useVersion: options.useVersion + useVersion: options.useVersion, }); this.logger.verbose.info("Calling after publish hook"); await this.hooks.afterPublish.promise();