Skip to content

Commit

Permalink
Fix version in commit string not being replaced. Align versioning sch…
Browse files Browse the repository at this point in the history
…eme with other plugins
  • Loading branch information
KetanReddy committed Dec 22, 2021
1 parent 475950b commit 59292fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
12 changes: 6 additions & 6 deletions plugins/version-file/__tests__/version-file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ describe("Version File Write Operations", () => {
await hooks.version.promise({bump: SEMVER.major})
expect(fs.readFileSync("VERSION", "utf-8")).toStrictEqual("2.0.0")
// check that the proper git operations were performed
expect(execPromise).toHaveBeenNthCalledWith(1, "git", ["commit", "-am", "'\"Bump version to: %s [skip ci]\"'"]);
expect(execPromise).toHaveBeenNthCalledWith(2, "git", ["tag", "2.0.0"]);
expect(execPromise).toHaveBeenNthCalledWith(1, "git", ["commit", "-am", "Bump version to: v2.0.0 [skip ci]"]);
expect(execPromise).toHaveBeenNthCalledWith(2, "git", ["tag", "v2.0.0"]);
});

test("It should version the file properly for minor releases", async () => {
Expand All @@ -97,8 +97,8 @@ describe("Version File Write Operations", () => {
await hooks.version.promise({bump: SEMVER.minor})
expect(fs.readFileSync("VERSION", "utf-8")).toStrictEqual("1.1.0");
// check that the proper git operations were performed
expect(execPromise).toHaveBeenNthCalledWith(1, "git", ["commit", "-am", "'\"Bump version to: %s [skip ci]\"'"]);
expect(execPromise).toHaveBeenNthCalledWith(2, "git", ["tag", "1.1.0"]);
expect(execPromise).toHaveBeenNthCalledWith(1, "git", ["commit", "-am", "Bump version to: v1.1.0 [skip ci]"]);
expect(execPromise).toHaveBeenNthCalledWith(2, "git", ["tag", "v1.1.0"]);
});

test("It should version the file properly for patch releases", async () => {
Expand All @@ -118,8 +118,8 @@ describe("Version File Write Operations", () => {
await hooks.version.promise({bump: SEMVER.patch})
expect(fs.readFileSync("VERSION", "utf-8")).toStrictEqual("1.0.1");
// check that the proper git operations were performed
expect(execPromise).toHaveBeenNthCalledWith(1, "git", ["commit", "-am", "'\"Bump version to: %s [skip ci]\"'"]);
expect(execPromise).toHaveBeenNthCalledWith(2, "git", ["tag", "1.0.1"]);
expect(execPromise).toHaveBeenNthCalledWith(1, "git", ["commit", "-am", "Bump version to: v1.0.1 [skip ci]"]);
expect(execPromise).toHaveBeenNthCalledWith(2, "git", ["tag", "v1.0.1"]);
});
})

Expand Down
5 changes: 2 additions & 3 deletions plugins/version-file/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as t from "io-ts";
import * as fs from "fs";
import { inc, ReleaseType } from "semver";

const VERSION_COMMIT_MESSAGE = `'"Bump version to: %s [skip ci]"'`;
const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);

Expand Down Expand Up @@ -97,10 +96,10 @@ export default class VersionFilePlugin implements IPlugin {
if (newVersion){
// Seal versions via commit and tag
await writeNewVersion(auto, newVersion, this.versionFile)
await execPromise("git", ["commit", "-am", VERSION_COMMIT_MESSAGE]);
await execPromise("git", ["commit", "-am", `Bump version to: v${newVersion} [skip ci]`]);
await execPromise("git", [
"tag",
newVersion
`v${newVersion}`
]);
auto.logger.verbose.info("Successfully versioned repo");
} else {
Expand Down

0 comments on commit 59292fb

Please sign in to comment.