Skip to content

Commit f32bec0

Browse files
bearomorphismLee-W
authored andcommitted
docs(bump): add example to version file
1 parent 90e5ee7 commit f32bec0

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

docs/commands/bump.md

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -470,36 +470,65 @@ Supported variables:
470470

471471
---
472472

473-
### `version_files` \*
473+
### `version_files`
474474

475475
It is used to identify the files or glob patterns which should be updated with the new version.
476-
It is also possible to provide a pattern for each file, separated by colons (`:`).
477476

478477
Commitizen will update its configuration file automatically (`pyproject.toml`, `.cz`) when bumping,
479478
regarding if the file is present or not in `version_files`.
480479

481-
\* Renamed from `files` to `version_files`.
480+
You may specify the `version_files` in your `pyproject.toml`, `.cz.toml` or `cz.toml` configuration file.
482481

483-
Some examples
482+
It is also possible to provide a pattern for each file, separated by a colon (e.g. `file:pattern`). See the below example for more details.
484483

485-
`pyproject.toml`, `.cz.toml` or `cz.toml`
484+
#### Example Configuration
486485

487486
```toml title="pyproject.toml"
488487
[tool.commitizen]
489488
version_files = [
490489
"src/__version__.py",
491490
"packages/*/pyproject.toml:version",
492-
"setup.py:version",
491+
"setup.json:version",
493492
]
494493
```
495494

496-
In the example above, we can see the reference `"setup.py:version"`.
497-
This means that it will find a file `setup.py` and will only make a change
498-
in a line containing the `version` substring.
495+
In the example configuration above, we can see the reference `"setup.json:version"`.
496+
497+
This means that it will find a file `setup.json` and will only change the lines that contain the substring `"version"`.
498+
499+
For example, if we have a file `setup.json` with the following content:
500+
501+
<!-- DEPENDENCY: repeated_version_number.json -->
502+
503+
```json title="setup.json"
504+
{
505+
"name": "magictool",
506+
"version": "1.2.3",
507+
"dependencies": {
508+
"lodash": "1.2.3"
509+
}
510+
}
511+
```
512+
513+
After running `cz bump 2.0.0`, the file will be updated to:
514+
515+
```diff title="setup.json"
516+
{
517+
"name": "magictool",
518+
- "version": "1.2.3",
519+
+ "version": "2.0.0",
520+
"dependencies": {
521+
"lodash": "1.2.3"
522+
}
523+
}
524+
```
499525

500526
!!! note
501527
Files can be specified using relative (to the execution) paths, absolute paths, or glob patterns.
502528

529+
!!! note
530+
(Historical note) This option was renamed from `files` to `version_files`.
531+
503532
---
504533

505534
### `bump_message`

0 commit comments

Comments
 (0)