Skip to content

Commit 8006f3e

Browse files
committed
Updated formatting documentation
1 parent 4fb5158 commit 8006f3e

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

docsrc/formatting-context.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Formatting context
2+
3+
These fields are available for
4+
5+
- version serializing
6+
- searching and replacing in files
7+
- commit messages
8+
- tag names
9+
- tag annotations
10+
11+
## Escaped characters
12+
13+
**`#`** The literal hash or [octothorpe](https://www.merriam-webster.com/dictionary/octothorpe) character.
14+
15+
**`;`** The literal semicolon character.
16+
17+
18+
## Date and time fields
19+
20+
**`now`** A Python datetime object representing the current local time, without a time zone reference.
21+
22+
**`utcnow`** A Python datetime object representing the current local time in the UTC time zone.
23+
24+
You can provide [additional formatting guidance](https://docs.python.org/3.11/library/datetime.html#strftime-and-strptime-format-codes) for datetime objects using formatting codes. Put the formatting codes after the field and a colon. For example, `{now:%Y-%m-%d}` would output the current local time as `2023-04-20`.
25+
26+
## Source code management fields
27+
28+
These fields will only have values if the code is in a Git or Mercurial repository.
29+
30+
**`commit_sha`** The latest commit reference.
31+
32+
**`distance_to_latest_tag`** The number of commits since the latest tag.
33+
34+
**`dirty`** A boolean indicating if the current repository has pending changes.
35+
36+
## Version fields
37+
38+
**`current_version`** The current version serialized as a string
39+
40+
**`current_<version part>`** Each version part defined by the [version configuration parsing regular expression](version-parts.md#version-configuration). The default configuration would have `current_major`, `current_minor`, and `current_patch` available.
41+
42+
**`new_version`** The new version serialized as a string
43+
44+
**`new_<version part>`** Each version part defined by the [version configuration parsing regular expression](version-parts.md#version-configuration). The default configuration would have `new_major`, `new_minor`, and `new_patch` available.
45+
46+
:::{note}
47+
The following fields are only available when serializing a version.
48+
:::
49+
50+
**`<version part>`** Each version part defined by the [version configuration parsing regular expression](version-parts.md#version-configuration). The default configuration would have `major`, `minor`, and `patch` available.
51+
52+
## Environment variables
53+
54+
Every environment variable available at runtime is included with a `$` prefix. For example if `USER` was in the environment, `{$USER}` would render that value.
55+
56+
If you use environment variables in your version serialization, you might want to ensure they are set by executing `export VAR=value` before running the `bump-my-version` command.

docsrc/index.md

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ caption: Contents
88
Introduction <readme>
99
usage
1010
configuration
11+
version-parts
12+
formatting-context
13+
search-and-replace
1114
cli
1215
api
1316
contributing

docsrc/search-and-replace.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ using this `.bumpversion.toml` will ensure only the line containing `MyProject`
1313
[tool.bumpversion]
1414
current_version = "1.5.6"
1515

16-
[[tool.bumpversion:files]]
16+
[[tool.bumpversion.files]]
1717
filename = "requirements.txt"
1818
search = "MyProject=={current_version}"
1919
replace = "MyProject=={new_version}"

0 commit comments

Comments
 (0)