commitizen-spdx-changelog 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- commitizen_spdx_changelog/__init__.py +13 -0
- commitizen_spdx_changelog/formatters/__init__.py +14 -0
- commitizen_spdx_changelog/formatters/spdx_markdown.py +142 -0
- commitizen_spdx_changelog/py.typed +0 -0
- commitizen_spdx_changelog-0.1.2.dist-info/METADATA +168 -0
- commitizen_spdx_changelog-0.1.2.dist-info/RECORD +8 -0
- commitizen_spdx_changelog-0.1.2.dist-info/WHEEL +4 -0
- commitizen_spdx_changelog-0.1.2.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Pablo Hörtner <redtux@pm.me>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
"""Entry point for the commitizen-spdx-changelog package.
|
|
6
|
+
|
|
7
|
+
Provides the package namespace and re-exports the public API.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
# src/commitizen_spdx_changelog/__init__.py
|
|
11
|
+
#
|
|
12
|
+
# This file is part of commitizen-spdx-changelog, a plugin
|
|
13
|
+
# for commitizen that generates changelogs in SPDX format.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Pablo Hörtner <redtux@pm.me>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
"""Changelog formatters for commitizen-spdx-changelog.
|
|
6
|
+
|
|
7
|
+
This subpackage contains the SPDX/REUSE-aware Markdown changelog format
|
|
8
|
+
implementation and its supporting utilities.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
# src/commitizen_spdx_changelog/formatters/__init__.py
|
|
12
|
+
#
|
|
13
|
+
# This file is part of commitizen-spdx-changelog, a plugin
|
|
14
|
+
# for commitizen that generates changelogs in SPDX format.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Pablo Hörtner <redtux@pm.me>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
"""SPDX/REUSE-aware Markdown changelog format for commitizen.
|
|
6
|
+
|
|
7
|
+
Compatible with REUSE/SPDX-compliant changelogs that carry a ``---``
|
|
8
|
+
delimited YAML frontmatter block (e.g. SPDX headers) before the Markdown
|
|
9
|
+
body. Registered under the ``commitizen.changelog_format`` entry point
|
|
10
|
+
as ``spdx-markdown``.
|
|
11
|
+
|
|
12
|
+
Note: importing this module directly, before anything else in the
|
|
13
|
+
process has imported ``commitizen.changelog_formats``, will raise an
|
|
14
|
+
``AttributeError`` due to a circular import inside commitizen's own
|
|
15
|
+
entry-point-loading machinery (it loads all registered
|
|
16
|
+
``commitizen.changelog_format`` plugins, including this one, from a
|
|
17
|
+
module-level dict comprehension). This never occurs during real ``cz``
|
|
18
|
+
usage, since commitizen's CLI bootstrap imports
|
|
19
|
+
``commitizen.changelog_formats`` before scanning plugins. It can occur
|
|
20
|
+
if a test imports this module cold — see ``tests/conftest.py`` for the
|
|
21
|
+
one-line warm-up import that avoids it for the test suite.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from __future__ import annotations
|
|
25
|
+
|
|
26
|
+
import io
|
|
27
|
+
from collections.abc import Sequence
|
|
28
|
+
from pathlib import Path
|
|
29
|
+
|
|
30
|
+
from commitizen.changelog import IncrementalMergeInfo, Metadata
|
|
31
|
+
from commitizen.changelog_formats.markdown import Markdown
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _strip_frontmatter(lines: Sequence[str]) -> tuple[list[str], int]:
|
|
35
|
+
"""Strip ``---``-delimited YAML frontmatter.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
lines: The input lines, which may start with ``---`` frontmatter.
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
A tuple of ``(clean_lines, offset)`` where ``clean_lines`` is the
|
|
42
|
+
content after the closing ``---`` and ``offset`` is the number of
|
|
43
|
+
frontmatter lines (0 if no frontmatter is detected).
|
|
44
|
+
"""
|
|
45
|
+
if not lines or lines[0].rstrip() != "---":
|
|
46
|
+
return list(lines), 0
|
|
47
|
+
|
|
48
|
+
in_fm = False
|
|
49
|
+
offset = 0
|
|
50
|
+
for i, line in enumerate(lines):
|
|
51
|
+
stripped = line.rstrip()
|
|
52
|
+
if stripped == "---":
|
|
53
|
+
offset += 1
|
|
54
|
+
if not in_fm:
|
|
55
|
+
in_fm = True
|
|
56
|
+
else:
|
|
57
|
+
return list(lines[i + 1 :]), offset
|
|
58
|
+
elif in_fm:
|
|
59
|
+
offset += 1
|
|
60
|
+
|
|
61
|
+
return list(lines), 0 # unclosed frontmatter — treat as no-op
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class SPDXMarkdown(Markdown):
|
|
65
|
+
"""Markdown changelog format with YAML frontmatter awareness.
|
|
66
|
+
|
|
67
|
+
Overrides two methods from :class:`commitizen.changelog_formats.markdown.Markdown`:
|
|
68
|
+
|
|
69
|
+
- ``get_metadata()`` — strips frontmatter via :func:`_strip_frontmatter`,
|
|
70
|
+
delegates to ``get_metadata_from_file()``, then shifts the returned
|
|
71
|
+
line indices by the frontmatter line count.
|
|
72
|
+
- ``get_latest_full_release()`` — same stripping and index shift applied
|
|
73
|
+
to ``get_latest_full_release_from_file()``.
|
|
74
|
+
|
|
75
|
+
Attributes:
|
|
76
|
+
config: The commitizen configuration object.
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
def __init__(self, config=None):
|
|
80
|
+
if config is None:
|
|
81
|
+
from commitizen.config.base_config import BaseConfig
|
|
82
|
+
|
|
83
|
+
config = BaseConfig()
|
|
84
|
+
if "encoding" not in config.settings:
|
|
85
|
+
config.update({"encoding": "utf-8"})
|
|
86
|
+
super().__init__(config)
|
|
87
|
+
|
|
88
|
+
def get_metadata(self, filepath: str) -> Metadata:
|
|
89
|
+
"""Extract changelog metadata with frontmatter offset correction.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
filepath: Path to the changelog file.
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
A :class:`commitizen.changelog.Metadata` instance with line
|
|
96
|
+
indices adjusted for stripped YAML frontmatter.
|
|
97
|
+
"""
|
|
98
|
+
file = Path(filepath)
|
|
99
|
+
if not file.is_file():
|
|
100
|
+
return Metadata()
|
|
101
|
+
|
|
102
|
+
encoding = self.config.settings.get("encoding", "utf-8")
|
|
103
|
+
raw = file.read_text(encoding=encoding)
|
|
104
|
+
clean_lines, offset = _strip_frontmatter(raw.splitlines(keepends=True))
|
|
105
|
+
|
|
106
|
+
meta = self.get_metadata_from_file(io.StringIO("".join(clean_lines)))
|
|
107
|
+
|
|
108
|
+
if meta.unreleased_start is not None:
|
|
109
|
+
meta.unreleased_start += offset
|
|
110
|
+
if meta.unreleased_end is not None:
|
|
111
|
+
meta.unreleased_end += offset
|
|
112
|
+
if meta.latest_version_position is not None:
|
|
113
|
+
meta.latest_version_position += offset
|
|
114
|
+
|
|
115
|
+
return meta
|
|
116
|
+
|
|
117
|
+
def get_latest_full_release(self, filepath: str) -> IncrementalMergeInfo:
|
|
118
|
+
"""Retrieve the latest full release info with frontmatter offset correction.
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
filepath: Path to the changelog file.
|
|
122
|
+
|
|
123
|
+
Returns:
|
|
124
|
+
An :class:`commitizen.changelog.IncrementalMergeInfo` with the
|
|
125
|
+
release index adjusted for stripped YAML frontmatter.
|
|
126
|
+
"""
|
|
127
|
+
file = Path(filepath)
|
|
128
|
+
if not file.is_file():
|
|
129
|
+
return IncrementalMergeInfo()
|
|
130
|
+
|
|
131
|
+
encoding = self.config.settings.get("encoding", "utf-8")
|
|
132
|
+
raw = file.read_text(encoding=encoding)
|
|
133
|
+
clean_lines, offset = _strip_frontmatter(raw.splitlines(keepends=True))
|
|
134
|
+
|
|
135
|
+
result = self.get_latest_full_release_from_file(
|
|
136
|
+
io.StringIO("".join(clean_lines))
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
return IncrementalMergeInfo(
|
|
140
|
+
name=result.name,
|
|
141
|
+
index=(result.index + offset) if result.index is not None else None,
|
|
142
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: commitizen-spdx-changelog
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Commitizen changelog format plugin with YAML frontmatter awareness for REUSE/SPDX-compliant changelogs
|
|
5
|
+
Keywords: commitizen,changelog,spdx,reuse,yaml,frontmatter
|
|
6
|
+
Author: Pablo Hörtner
|
|
7
|
+
Author-email: Pablo Hörtner <redtux@pm.me>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Requires-Dist: commitizen>=4.16.3
|
|
15
|
+
Requires-Python: >=3.13
|
|
16
|
+
Project-URL: Homepage, https://github.com/redtux/commitizen-spdx-changelog
|
|
17
|
+
Project-URL: Issues, https://github.com/redtux/commitizen-spdx-changelog/issues
|
|
18
|
+
Project-URL: Source, https://github.com/redtux/commitizen-spdx-changelog
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
<!--
|
|
22
|
+
SPDX-FileCopyrightText: 2026 Pablo Hörtner <redtux@pm.me>
|
|
23
|
+
|
|
24
|
+
SPDX-License-Identifier: Apache-2.0
|
|
25
|
+
-->
|
|
26
|
+
|
|
27
|
+
# 𝗰𝗼𝗺𝗺𝗶𝘁𝗶𝘇𝗲𝗻-𝚜𝚙𝚍𝚡-𝓬𝓱𝓪𝓷𝓰𝓮𝓵𝓸𝓰
|
|
28
|
+
|
|
29
|
+
[![Typing SVG][typing-svg-badge]][typing-svg-link]
|
|
30
|
+
|
|
31
|
+
[![License][license-badge]][license-link] [![PyPI][pypi-badge]][pypi-link]
|
|
32
|
+
[![Python][python-badge]][pypi-link] [![CI][ci-badge]][ci-link]
|
|
33
|
+
[![Release][release-badge]][release-link]
|
|
34
|
+
|
|
35
|
+
A [commitizen] changelog format plugin with YAML frontmatter awareness —
|
|
36
|
+
designed for REUSE/SPDX-compliant changelogs. No more false version detection
|
|
37
|
+
from license headers like `Apache-2.0`.
|
|
38
|
+
|
|
39
|
+
> [!WARNING]
|
|
40
|
+
> _This project is in early development._
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
- [x] **SPDX-aware** — strips `---`-delimited YAML frontmatter before parsing
|
|
45
|
+
- [x] **Correct version detection** — no false positives from `Apache-2.0` style
|
|
46
|
+
headers
|
|
47
|
+
- [x] **Drop-in replacement** — extends commitizen's built-in `Markdown` format
|
|
48
|
+
- [x] **Zero extra config** — just set `changelog_format = "spdx-markdown"`
|
|
49
|
+
|
|
50
|
+
## Why do I need this?
|
|
51
|
+
|
|
52
|
+
If you keep your changelog in `docs/changelog.md` instead of the project root,
|
|
53
|
+
placing it alongside your documentation lets readers of your published site who
|
|
54
|
+
might not directly browse the git repository stay informed about recent changes.
|
|
55
|
+
|
|
56
|
+
Documentation generators like [Zensical], [Docusaurus], and tools using Google's
|
|
57
|
+
[Open Knowledge Format (OKF)][okf] require a YAML front matter for `meta` data.
|
|
58
|
+
|
|
59
|
+
When you apply a [REUSE/SPDX][reuse] license header with `reuse annotate`, the
|
|
60
|
+
header lands as a YAML comment inside the front matter, not as an HTML comment:
|
|
61
|
+
|
|
62
|
+
<!-- REUSE-IgnoreStart -->
|
|
63
|
+
|
|
64
|
+
- `# SPDX-License-Identifier: Apache-2.0`
|
|
65
|
+
|
|
66
|
+
<!-- REUSE-IgnoreEnd -->
|
|
67
|
+
|
|
68
|
+
**The catch:** commitizen's built-in `Markdown` format does not understand YAML
|
|
69
|
+
front matter. It reads `Apache-2.0` as a version number, causing
|
|
70
|
+
`cz bump --changelog` to fail silently or produce wrong results.
|
|
71
|
+
|
|
72
|
+
> [!NOTE]
|
|
73
|
+
> This plugin strips the front matter before parsing, so your changelog stays
|
|
74
|
+
> compliant, doc-generator-friendly, and commitizen-compatible — all at once.
|
|
75
|
+
|
|
76
|
+
## Getting started
|
|
77
|
+
|
|
78
|
+
### Installation
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
uv add commitizen-spdx-changelog
|
|
82
|
+
# or: pip install commitizen-spdx-changelog
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
> [!TIP]
|
|
86
|
+
> See the [docs landing page](docs/index.md) for a full overview, and the
|
|
87
|
+
> [usage guide](docs/guide.md) for furher setup and workflow instructions.
|
|
88
|
+
|
|
89
|
+
### Configuration
|
|
90
|
+
|
|
91
|
+
In `pyproject.toml`:
|
|
92
|
+
|
|
93
|
+
```toml
|
|
94
|
+
[tool.commitizen]
|
|
95
|
+
changelog_format = "spdx-markdown"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Usage
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
cz bump --changelog
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The plugin handles changelogs with SPDX frontmatter like:
|
|
105
|
+
|
|
106
|
+
```markdown
|
|
107
|
+
---
|
|
108
|
+
# SPDX-FileCopyrightText: 2026 Pablo Hörtner <redtux@pm.me>
|
|
109
|
+
#
|
|
110
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
111
|
+
|
|
112
|
+
icon: lucide/git-commit-vertical
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
# Changelog
|
|
116
|
+
|
|
117
|
+
## 0.4.0 (2026-06-08)
|
|
118
|
+
...
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Development
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
direnv allow
|
|
125
|
+
uv sync --group dev
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
> [!TIP]
|
|
129
|
+
> Running `direnv allow` will activate the [devbox] environment automatically.
|
|
130
|
+
> See the [Devbox guide](docs/devbox.md) for all available commands and tools.
|
|
131
|
+
|
|
132
|
+
## Contributing
|
|
133
|
+
|
|
134
|
+
> [!NOTE]
|
|
135
|
+
> Bug reports, feature requests, and pull requests are welcome.
|
|
136
|
+
|
|
137
|
+
- See [docs/contributing.md](docs/contributing.md) for guidelines.
|
|
138
|
+
|
|
139
|
+
For documentation contributions, please follow these principles:
|
|
140
|
+
|
|
141
|
+
Write for humans, keep it minimal, update docs with code, delete dead content.
|
|
142
|
+
Every page in `docs/` and the project `README.md` are held to these standards.
|
|
143
|
+
|
|
144
|
+
## License
|
|
145
|
+
|
|
146
|
+
Distributed under the terms of the [Apache License 2.0](LICENSE.md).
|
|
147
|
+
|
|
148
|
+
- Copyright © 2026 Pablo Hörtner
|
|
149
|
+
|
|
150
|
+
<!-- References -->
|
|
151
|
+
|
|
152
|
+
[ci-badge]: https://badgen.net/github/checks/redtux/commitizen-spdx-changelog
|
|
153
|
+
[ci-link]: https://github.com/redtux/commitizen-spdx-changelog/actions
|
|
154
|
+
[commitizen]: https://commitizen-tools.github.io/commitizen/
|
|
155
|
+
[devbox]: https://github.com/jetify-com/devbox
|
|
156
|
+
[docusaurus]: https://docusaurus.io/
|
|
157
|
+
[license-badge]: https://badgen.net/github/license/redtux/commitizen-spdx-changelog
|
|
158
|
+
[license-link]: LICENSE.md
|
|
159
|
+
[okf]: https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md
|
|
160
|
+
[pypi-badge]: https://badgen.net/pypi/v/commitizen-spdx-changelog
|
|
161
|
+
[pypi-link]: https://pypi.org/project/commitizen-spdx-changelog/
|
|
162
|
+
[python-badge]: https://badgen.net/pypi/python/commitizen-spdx-changelog
|
|
163
|
+
[release-badge]: https://badgen.net/github/release/redtux/commitizen-spdx-changelog
|
|
164
|
+
[release-link]: https://github.com/redtux/commitizen-spdx-changelog/releases
|
|
165
|
+
[reuse]: https://reuse.software/
|
|
166
|
+
[typing-svg-badge]: https://readme-typing-svg.demolab.com?font=Fira+Code&pause=1000&width=435&lines=SPDX-compliant+Commitizen+Changelogs
|
|
167
|
+
[typing-svg-link]: https://git.io/typing-svg
|
|
168
|
+
[zensical]: https://zensical.org/
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
commitizen_spdx_changelog/__init__.py,sha256=JeuT7vZA__OchhhAzoA74u5BIFnnTpMjukq8_vuBNXU,392
|
|
2
|
+
commitizen_spdx_changelog/formatters/__init__.py,sha256=mxXxvueP2p5pyl_Y35HdoIfH9K2jESGrmpoKNWU6-ZI,454
|
|
3
|
+
commitizen_spdx_changelog/formatters/spdx_markdown.py,sha256=h3oPis3rBqUYpRuPfleQ6P8i1icZ_i4W21X51mydiI4,5084
|
|
4
|
+
commitizen_spdx_changelog/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
commitizen_spdx_changelog-0.1.2.dist-info/WHEEL,sha256=s49dN1sxqzkgPplo4QuUaKomil-_cbDzeLK4-pZKD-A,81
|
|
6
|
+
commitizen_spdx_changelog-0.1.2.dist-info/entry_points.txt,sha256=TL_iZ11fIGMCO1ikcrpk_FQ5oMGJX0urLspCbe-eY0M,111
|
|
7
|
+
commitizen_spdx_changelog-0.1.2.dist-info/METADATA,sha256=KJwsD8F14cB13fOrSKZcvDMIFAkSk8ERohqqKwn2x4A,5555
|
|
8
|
+
commitizen_spdx_changelog-0.1.2.dist-info/RECORD,,
|