Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create major version at last release tag #2175

Merged
merged 1 commit into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/core/src/__tests__/major-version-branches.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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"]);
});
});
12 changes: 7 additions & 5 deletions packages/core/src/auto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down Expand Up @@ -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}` : ""}`
);
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -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();
Expand Down