Skip to content

Commit

Permalink
Merge pull request #2175 from intuit/version-branches-bug
Browse files Browse the repository at this point in the history
create major version at last release tag
  • Loading branch information
hipstersmoothie authored Mar 21, 2022
2 parents 86e2625 + 7eb8ef8 commit c224104
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
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

0 comments on commit c224104

Please sign in to comment.