Skip to content

Commit

Permalink
fix: don't amend commits, ever
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Sep 15, 2021
1 parent 2c7ef2f commit 26c7f80
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-git/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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(),
);
});
Expand Down
4 changes: 1 addition & 3 deletions packages/plugin-git/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>("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}`],
];

Expand Down

0 comments on commit 26c7f80

Please sign in to comment.