Skip to content

Commit c87eba6

Browse files
Allow "commit" option to describe a module containing commit functions (changesets#768)
* Add CommitFunctions and update config with defaults * Add changeset * add checks and types for new commit option * moved default to cli * update tests * fix build * rename commit fns * add option for skipCI * update tests * move commit logic to cli * update tests for commit * allow disabling commit for only one of add/version * update docs * update tests * Apply suggestions from code review Co-authored-by: Mateusz Burzyński <[email protected]> * remove unnecessary partial * change option name * Apply suggestions from code review Co-authored-by: Mateusz Burzyński <[email protected]> * Small tweaks after review * Tweak changesets Co-authored-by: Mateusz Burzyński <[email protected]>
1 parent 8830415 commit c87eba6

22 files changed

+526
-303
lines changed

.changeset/rare-meals-switch.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@changesets/types": major
3+
---
4+
5+
`commit` properties of config types were adjusted to account for this option potentially pointing to a module path.

.changeset/stupid-dogs-eat.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@changesets/cli": minor
3+
---
4+
5+
Allow `"commit"` option to be more configurable. You can now point to a module (using a module name or a relative path) that might contain `getAddMessage` and/or `getVersionMessage`. This allows you to configure how the commit message is generated, if `[skip ci]` gets included, etc.

.changeset/tough-rivers-decide.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@changesets/apply-release-plan": major
3+
---
4+
5+
This module is no longer responsible for commiting files - this responsibility has been moved entirely to `@changesets/cli`.

.changeset/yellow-cows-juggle.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@changesets/config": major
3+
---
4+
5+
The parsed config now normalzied the commit option to either `false` or a tuple describing what module should be loaded to resolve commit functions.

docs/config-file-options.md

+23-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,30 @@ Changesets has a minimal amount of configuration options. Mostly these are for w
1616

1717
> NOTE: the `linked`, `updateInternalDependencies`, and `ignore` options are only for behaviour in monorepos.
1818
19-
## `commit` (`true` | `false`)
19+
## `commit` (`boolean`, or module path as a `string`, or a tuple like `[modulePath: string, options: any]`)
2020

21-
This argument sets whether the `changeset add` command and the `changeset publish` command will also add and commit the changed files using git. By default, we do not commit the files, and leave it to the user to commit the files.
21+
This option is for setting if the `changeset add` command and the `changeset version` commands will also add and commit the changed files using git, and how the commit messages should be generated for them.
22+
23+
By default, we do not commit the files, and leave it to the user to commit the files. If it is `true`, we use the default commit message generator (`["@changesets/cli/commit", { "skipCI": "version" }]`). Setting it to a string and options tuple specifies a path from where we will load the commit message generation functions. It expects to be a file that exports one or both of the following:
24+
25+
```
26+
{
27+
getAddMessage,
28+
getVersionMessage
29+
}
30+
```
31+
32+
If one of the methods is not present then we will not commit the files changed for that command.
33+
34+
You would specify a custom commit message generator with:
35+
36+
```json
37+
{
38+
"commit": ["../scripts/commit.js", { "customOption": true }]
39+
}
40+
```
41+
42+
This is similar to how the [changelog generator functions work](#changelog-false-or-a-path).
2243

2344
## `access` (`restricted` | `public`)
2445

packages/apply-release-plan/src/createVersionCommit.test.ts

-124
This file was deleted.

packages/apply-release-plan/src/createVersionCommit.ts

-26
This file was deleted.

0 commit comments

Comments
 (0)