Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 059d646

Browse files
Merge branch 'master' into feat/unicode
2 parents 69c90ab + 114501d commit 059d646

File tree

15 files changed

+228
-205
lines changed

15 files changed

+228
-205
lines changed

‎.pre-commit-config.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ repos:
4444
args: ["--write-changes", "--ignore-words-list", "asend"]
4545

4646
- repo: https://github.com/commitizen-tools/commitizen
47-
rev: v3.5.2 # automatically updated by Commitizen
47+
rev: v3.5.4 # automatically updated by Commitizen
4848
hooks:
4949
- id: commitizen
5050
- id: commitizen-branch

‎CHANGELOG.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11

2+
## v3.5.4 (2023年07月29日)
3+
4+
### Refactor
5+
6+
- replace SemVer type literals by respective constants
7+
8+
## v3.5.3 (2023年07月15日)
9+
10+
### Fix
11+
12+
- Treat $version the same as unset tag_format in ScmProvider
13+
14+
### Refactor
15+
16+
- Make tag_format properly default to $version
17+
218
## v3.5.2 (2023年06月25日)
319

420
### Fix

‎commitizen/__version__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.5.2"
1+
__version__ = "3.5.4"

‎commitizen/bump.py‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from collections import OrderedDict
66
from string import Template
77

8-
from commitizen.defaults import bump_message, encoding
8+
from commitizen.defaults import MAJOR, MINOR, PATCH, bump_message, encoding
99
from commitizen.exceptions import CurrentVersionNotFoundError
1010
from commitizen.git import GitCommit, smart_open
1111
from commitizen.version_schemes import DEFAULT_SCHEME, Version, VersionScheme
@@ -34,11 +34,11 @@ def find_increment(
3434
new_increment = increments_map[match_pattern]
3535
break
3636

37-
if increment == "MAJOR":
37+
if increment == MAJOR:
3838
break
39-
elif increment == "MINOR" and new_increment == "MAJOR":
39+
elif increment == MINOR and new_increment == MAJOR:
4040
increment = new_increment
41-
elif increment == "PATCH" or increment is None:
41+
elif increment == PATCH or increment is None:
4242
increment = new_increment
4343

4444
return increment
@@ -114,7 +114,7 @@ def _version_to_regex(version: str) -> str:
114114

115115
def normalize_tag(
116116
version: Version | str,
117-
tag_format: str|None=None,
117+
tag_format: str,
118118
scheme: VersionScheme | None = None,
119119
) -> str:
120120
"""The tag and the software version might be different.
@@ -131,9 +131,6 @@ def normalize_tag(
131131
scheme = scheme or DEFAULT_SCHEME
132132
version = scheme(version) if isinstance(version, str) else version
133133

134-
if not tag_format:
135-
return str(version)
136-
137134
major, minor, patch = version.release
138135
prerelease = version.prerelease or ""
139136

‎commitizen/commands/changelog.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def __init__(self, config: BaseConfig, args):
5858
or defaults.change_type_order
5959
)
6060
self.rev_range = args.get("rev_range")
61-
self.tag_format=args.get("tag_format") orself.config.settings.get(
62-
"tag_format"
61+
self.tag_format: str=(
62+
args.get("tag_format") orself.config.settings["tag_format"]
6363
)
6464
self.merge_prerelease = args.get(
6565
"merge_prerelease"

‎commitizen/commands/init.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from commitizen.__version__ import __version__
1111
from commitizen.config import BaseConfig, JsonConfig, TomlConfig, YAMLConfig
1212
from commitizen.cz import registry
13-
from commitizen.defaults import config_files
13+
from commitizen.defaults import DEFAULT_SETTINGS, config_files
1414
from commitizen.exceptions import InitFailedError, NoAnswersError
1515
from commitizen.git import get_latest_tag_name, get_tag_names, smart_open
1616
from commitizen.version_schemes import KNOWN_SCHEMES, Version, get_version_scheme
@@ -204,14 +204,15 @@ def _ask_tag_format(self, latest_tag) -> str:
204204
f'Is "{tag_format}" the correct tag format?', style=self.cz.style
205205
).unsafe_ask()
206206

207+
default_format = DEFAULT_SETTINGS["tag_format"]
207208
if not is_correct_format:
208209
tag_format = questionary.text(
209-
'Please enter the correct version format: (default: "$version")',
210+
f'Please enter the correct version format: (default: "{default_format}")',
210211
style=self.cz.style,
211212
).unsafe_ask()
212213

213214
if not tag_format:
214-
tag_format = "$version"
215+
tag_format = default_format
215216
return tag_format
216217

217218
def _ask_version_provider(self) -> str:

‎commitizen/defaults.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Settings(TypedDict, total=False):
3939
version_provider: str | None
4040
version_scheme: str | None
4141
version_type: str | None
42-
tag_format: str|None
42+
tag_format: str
4343
bump_message: str | None
4444
allow_abort: bool
4545
allowed_prefixes: list[str]
@@ -75,7 +75,7 @@ class Settings(TypedDict, total=False):
7575
"version_files": [],
7676
"version_provider": "commitizen",
7777
"version_scheme": None,
78-
"tag_format": None, # example v$version
78+
"tag_format": "$version", # example v$version
7979
"bump_message": None, # bumped v$current_version to $new_version
8080
"allow_abort": False,
8181
"allowed_prefixes": [

‎commitizen/providers.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ class ScmProvider(VersionProvider):
195195

196196
def _tag_format_matcher(self) -> Callable[[str], str | None]:
197197
version_scheme = get_version_scheme(self.config)
198-
pattern = (
199-
self.config.settings.get("tag_format") orversion_scheme.parser.pattern
200-
)
198+
pattern = self.config.settings["tag_format"]
199+
ifpattern=="$version":
200+
pattern=version_scheme.parser.pattern
201201
for var, tag_pattern in self.TAG_FORMAT_REGEXS.items():
202202
pattern = pattern.replace(var, tag_pattern)
203203

‎commitizen/version_schemes.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def increment_base(self, increment: str | None = None) -> str:
191191
elif increment == PATCH:
192192
base[PATCH] += 1
193193

194-
return f"{base['MAJOR']}.{base['MINOR']}.{base['PATCH']}"
194+
return f"{base[MAJOR]}.{base[MINOR]}.{base[PATCH]}"
195195

196196
def bump(
197197
self,

‎docs/bump.md‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,17 @@ cz -nr 21 bump
317317
318318
### `tag_format`
319319
320-
It is used to read the format from the git tags, and also to generate the tags.
320+
`tag_format` and `version_scheme` are combined to make Git tag names from versions.
321+
322+
These are used in:
323+
324+
* `cz bump`: Find previous release tag (exact match) and generate new tag.
325+
* Find previous release tags in `cz changelog`.
326+
* If `--incremental`: Using latest version found in the changelog, scan existing Git tags with 89\% similarity match.
327+
* `--rev-range` is converted to Git tag names with `tag_format` before searching Git history.
328+
* If the `scm` `version_provider` is used, it uses different regexes to find the previous version tags:
329+
* If `tag_format` is set to `$version` (default): `VersionProtocol.parser` (allows `v` prefix)
330+
* If `tag_format` is set: Custom regex similar to SemVer (not as lenient as PEP440 e.g. on dev-releases)
321331
322332
Commitizen supports 2 types of formats, a simple and a more complex.
323333
@@ -336,7 +346,7 @@ In your `pyproject.toml` or `.cz.toml`
336346
tag_format = "v$major.$minor.$patch$prerelease"
337347
```
338348
339-
The variables must be preceded by a `$` sign.
349+
The variables must be preceded by a `$` sign. Default is `$version`.
340350
341351
Supported variables:
342352

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /