diff --git a/CHANGELOG.md b/CHANGELOG.md index 8035816..075b5af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ## **WORK IN PROGRESS** * New plugin `license` to check for outdated license years * New plugin `manual-review` to do manual changes before committing +* Fix: `git` plugin never `amends` commits ## 3.0.0 (2021-09-15) * Split into plugins diff --git a/packages/plugin-git/src/index.test.ts b/packages/plugin-git/src/index.test.ts index 59274d1..3733773 100644 --- a/packages/plugin-git/src/index.test.ts +++ b/packages/plugin-git/src/index.test.ts @@ -178,7 +178,7 @@ This is the changelog.`); ); }); - it("amends the commit in lerna mode", async () => { + it("does not amend the commit, not even in lerna mode", async () => { const gitPlugin = new GitPlugin(); const context = createMockContext({ plugins: [gitPlugin], cwd: testFSRoot }); const newVersion = "1.2.3"; @@ -190,9 +190,9 @@ This is the changelog.`); context.sys.mockExec(() => ""); await gitPlugin.executeStage(context, DefaultStages.commit); - expect(context.sys.exec).toHaveBeenCalledWith( + expect(context.sys.exec).not.toHaveBeenCalledWith( "git", - ["commit", "--amend", "-F", ".commitmessage"], + expect.arrayContaining(["--amend"]), expect.anything(), ); }); diff --git a/packages/plugin-git/src/index.ts b/packages/plugin-git/src/index.ts index b8ef3d8..1266c38 100644 --- a/packages/plugin-git/src/index.ts +++ b/packages/plugin-git/src/index.ts @@ -160,13 +160,11 @@ ${context.getData("changelog_new")}`; await fs.writeFile(path.join(context.cwd, ".commitmessage"), commitMessage); } - const lerna = context.hasData("lerna") && !!context.getData("lerna"); - // And commit stuff const newVersion = context.getData("version_new"); const commands = [ ["git", "add", "-A", "--", ":(exclude).commitmessage"], - ["git", "commit", ...(lerna ? ["--amend"] : []), "-F", ".commitmessage"], + ["git", "commit", "-F", ".commitmessage"], ["git", "tag", "-a", `v${newVersion}`, "-m", `v${newVersion}`], ];