Skip to content

Commit

Permalink
Allow "commit" option to describe a module containing commit functi…
Browse files Browse the repository at this point in the history
…ons (#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 <mateuszburzynski@gmail.com>

* remove unnecessary partial

* change option name

* Apply suggestions from code review

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>

* Small tweaks after review

* Tweak changesets

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
  • Loading branch information
rohit-gohri and Andarist committed Mar 27, 2022
1 parent 8830415 commit c87eba6
Show file tree
Hide file tree
Showing 22 changed files with 526 additions and 303 deletions.
5 changes: 5 additions & 0 deletions .changeset/rare-meals-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/types": major
---

`commit` properties of config types were adjusted to account for this option potentially pointing to a module path.
5 changes: 5 additions & 0 deletions .changeset/stupid-dogs-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/cli": minor
---

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.
5 changes: 5 additions & 0 deletions .changeset/tough-rivers-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/apply-release-plan": major
---

This module is no longer responsible for commiting files - this responsibility has been moved entirely to `@changesets/cli`.
5 changes: 5 additions & 0 deletions .changeset/yellow-cows-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/config": major
---

The parsed config now normalzied the commit option to either `false` or a tuple describing what module should be loaded to resolve commit functions.
25 changes: 23 additions & 2 deletions docs/config-file-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,30 @@ Changesets has a minimal amount of configuration options. Mostly these are for w

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

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.
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.

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:

```
{
getAddMessage,
getVersionMessage
}
```

If one of the methods is not present then we will not commit the files changed for that command.

You would specify a custom commit message generator with:

```json
{
"commit": ["../scripts/commit.js", { "customOption": true }]
}
```

This is similar to how the [changelog generator functions work](#changelog-false-or-a-path).

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

Expand Down
124 changes: 0 additions & 124 deletions packages/apply-release-plan/src/createVersionCommit.test.ts

This file was deleted.

26 changes: 0 additions & 26 deletions packages/apply-release-plan/src/createVersionCommit.ts

This file was deleted.

Loading

0 comments on commit c87eba6

Please sign in to comment.