Skip to content

Commit 21ebb79

Browse files
authored
Merge branch 'master' into fix-cz-bump-subdir-path​
2 parents b91ce9f + 35f5c23 commit 21ebb79

11 files changed

+186
-10
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ repos:
4848
- tomli
4949

5050
- repo: https://github.com/commitizen-tools/commitizen
51-
rev: v4.4.1 # automatically updated by Commitizen
51+
rev: v4.6.0 # automatically updated by Commitizen
5252
hooks:
5353
- id: commitizen
5454
- id: commitizen-branch

CHANGELOG.md

+23
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
## v4.6.0 (2025-04-13)
2+
3+
### Feat
4+
5+
- **changelog**: expose commit parents' digests when processing commits
6+
- **git**: add parents' digests in commit information
7+
8+
## v4.5.1 (2025-04-09)
9+
10+
### Fix
11+
12+
- print which tag is invalid
13+
14+
## v4.5.0 (2025-04-04)
15+
16+
### Feat
17+
18+
- **init**: set uv to default value if both pyproject.toml and uv.lock present
19+
20+
### Fix
21+
22+
- **commands/init**: add missing uv provider to "cz init"
23+
124
## v4.4.1 (2025-03-02)
225

326
### Fix

commitizen/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "4.4.1"
1+
__version__ = "4.6.0"

commitizen/changelog.py

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def process_commit_message(
172172
):
173173
message: dict = {
174174
"sha1": commit.rev,
175+
"parents": commit.parents,
175176
"author": commit.author,
176177
"author_email": commit.author_email,
177178
**parsed.groupdict(),

commitizen/commands/init.py

+11
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ class ProjectInfo:
2424
def has_pyproject(self) -> bool:
2525
return os.path.isfile("pyproject.toml")
2626

27+
@property
28+
def has_uv_lock(self) -> bool:
29+
return os.path.isfile("uv.lock")
30+
2731
@property
2832
def has_setup(self) -> bool:
2933
return os.path.isfile("setup.py")
@@ -32,6 +36,10 @@ def has_setup(self) -> bool:
3236
def has_pre_commit_config(self) -> bool:
3337
return os.path.isfile(".pre-commit-config.yaml")
3438

39+
@property
40+
def is_python_uv(self) -> bool:
41+
return self.has_pyproject and self.has_uv_lock
42+
3543
@property
3644
def is_python_poetry(self) -> bool:
3745
if not self.has_pyproject:
@@ -228,13 +236,16 @@ def _ask_version_provider(self) -> str:
228236
"npm": "npm: Get and set version from package.json:project.version field",
229237
"pep621": "pep621: Get and set version from pyproject.toml:project.version field",
230238
"poetry": "poetry: Get and set version from pyproject.toml:tool.poetry.version field",
239+
"uv": "uv: Get and Get and set version from pyproject.toml and uv.lock",
231240
"scm": "scm: Fetch the version from git and does not need to set it back",
232241
}
233242

234243
default_val = "commitizen"
235244
if self.project_info.is_python:
236245
if self.project_info.is_python_poetry:
237246
default_val = "poetry"
247+
elif self.project_info.is_python_uv:
248+
default_val = "uv"
238249
else:
239250
default_val = "pep621"
240251
elif self.project_info.is_rust_cargo:

commitizen/git.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,20 @@ def __eq__(self, other) -> bool:
4444

4545
class GitCommit(GitObject):
4646
def __init__(
47-
self, rev, title, body: str = "", author: str = "", author_email: str = ""
47+
self,
48+
rev,
49+
title,
50+
body: str = "",
51+
author: str = "",
52+
author_email: str = "",
53+
parents: list[str] | None = None,
4854
):
4955
self.rev = rev.strip()
5056
self.title = title.strip()
5157
self.body = body.strip()
5258
self.author = author.strip()
5359
self.author_email = author_email.strip()
60+
self.parents = parents or []
5461

5562
@property
5663
def message(self):
@@ -137,14 +144,17 @@ def get_commits(
137144
for rev_and_commit in git_log_entries:
138145
if not rev_and_commit:
139146
continue
140-
rev, title, author, author_email, *body_list = rev_and_commit.split("\n")
147+
rev, parents, title, author, author_email, *body_list = rev_and_commit.split(
148+
"\n"
149+
)
141150
if rev_and_commit:
142151
git_commit = GitCommit(
143152
rev=rev.strip(),
144153
title=title.strip(),
145154
body="\n".join(body_list).strip(),
146155
author=author,
147156
author_email=author_email,
157+
parents=[p for p in parents.strip().split(" ") if p],
148158
)
149159
git_commits.append(git_commit)
150160
return git_commits
@@ -286,7 +296,7 @@ def smart_open(*args, **kargs):
286296
def _get_log_as_str_list(start: str | None, end: str, args: str) -> list[str]:
287297
"""Get string representation of each log entry"""
288298
delimiter = "----------commit-delimiter----------"
289-
log_format: str = "%H%n%s%n%an%n%ae%n%b"
299+
log_format: str = "%H%n%P%n%s%n%an%n%ae%n%b"
290300
git_log_cmd = (
291301
f"git -c log.showSignature=False log --pretty={log_format}{delimiter} {args}"
292302
)

commitizen/tags.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ def extract_version(self, tag: GitTag) -> Version:
146146
m for regex in self.version_regexes if (m := regex.fullmatch(tag.name))
147147
)
148148
if not (m := next(candidates, None)):
149-
raise InvalidVersion()
149+
raise InvalidVersion(
150+
f"Invalid version tag: '{tag.name}' does not match any configured tag format"
151+
)
150152
if "version" in m.groupdict():
151153
return self.scheme(m.group("version"))
152154

docs/customization.md

+4
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,16 @@ Each `Change` has the following fields:
507507
| scope | `str | None` | An optional scope |
508508
| message | `str` | The commit message body |
509509
| sha1 | `str` | The commit `sha1` |
510+
| parents | `list[str]` | The parent commit(s) `sha1`(s) |
510511
| author | `str` | The commit author name |
511512
| author_email | `str` | The commit author email |
512513

513514
!!! Note
514515
The field values depend on the customization class and/or the settings you provide
515516

517+
The `parents` field can be used to identify merge commits and generate a changelog based on those. Another use case
518+
is listing commits that belong to the same pull request.
519+
516520
When using another template (either provided by a plugin or by yourself), you can also pass extra template variables
517521
by:
518522

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "commitizen"
3-
version = "4.4.1"
3+
version = "4.6.0"
44
description = "Python commitizen client tool"
55
authors = [{ name = "Santiago Fraire", email = "[email protected]" }]
66
maintainers = [
@@ -88,7 +88,7 @@ build-backend = "poetry.core.masonry.api"
8888

8989

9090
[tool.commitizen]
91-
version = "4.4.1"
91+
version = "4.6.0"
9292
tag_format = "v$version"
9393
version_files = [
9494
"pyproject.toml:version",

0 commit comments

Comments
 (0)