commitizen-spdx-changelog 0.1.2__tar.gz

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.
@@ -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,148 @@
1
+ <!--
2
+ SPDX-FileCopyrightText: 2026 Pablo Hรถrtner <redtux@pm.me>
3
+
4
+ SPDX-License-Identifier: Apache-2.0
5
+ -->
6
+
7
+ # ๐—ฐ๐—ผ๐—บ๐—บ๐—ถ๐˜๐—ถ๐˜‡๐—ฒ๐—ป-๐šœ๐š™๐š๐šก-๐“ฌ๐“ฑ๐“ช๐“ท๐“ฐ๐“ฎ๐“ต๐“ธ๐“ฐ
8
+
9
+ [![Typing SVG][typing-svg-badge]][typing-svg-link]
10
+
11
+ [![License][license-badge]][license-link] [![PyPI][pypi-badge]][pypi-link]
12
+ [![Python][python-badge]][pypi-link] [![CI][ci-badge]][ci-link]
13
+ [![Release][release-badge]][release-link]
14
+
15
+ A [commitizen] changelog format plugin with YAML frontmatter awareness โ€”
16
+ designed for REUSE/SPDX-compliant changelogs. No more false version detection
17
+ from license headers like `Apache-2.0`.
18
+
19
+ > [!WARNING]
20
+ > _This project is in early development._
21
+
22
+ ## Features
23
+
24
+ - [x] **SPDX-aware** โ€” strips `---`-delimited YAML frontmatter before parsing
25
+ - [x] **Correct version detection** โ€” no false positives from `Apache-2.0` style
26
+ headers
27
+ - [x] **Drop-in replacement** โ€” extends commitizen's built-in `Markdown` format
28
+ - [x] **Zero extra config** โ€” just set `changelog_format = "spdx-markdown"`
29
+
30
+ ## Why do I need this?
31
+
32
+ If you keep your changelog in `docs/changelog.md` instead of the project root,
33
+ placing it alongside your documentation lets readers of your published site who
34
+ might not directly browse the git repository stay informed about recent changes.
35
+
36
+ Documentation generators like [Zensical], [Docusaurus], and tools using Google's
37
+ [Open Knowledge Format (OKF)][okf] require a YAML front matter for `meta` data.
38
+
39
+ When you apply a [REUSE/SPDX][reuse] license header with `reuse annotate`, the
40
+ header lands as a YAML comment inside the front matter, not as an HTML comment:
41
+
42
+ <!-- REUSE-IgnoreStart -->
43
+
44
+ - `# SPDX-License-Identifier: Apache-2.0`
45
+
46
+ <!-- REUSE-IgnoreEnd -->
47
+
48
+ **The catch:** commitizen's built-in `Markdown` format does not understand YAML
49
+ front matter. It reads `Apache-2.0` as a version number, causing
50
+ `cz bump --changelog` to fail silently or produce wrong results.
51
+
52
+ > [!NOTE]
53
+ > This plugin strips the front matter before parsing, so your changelog stays
54
+ > compliant, doc-generator-friendly, and commitizen-compatible โ€” all at once.
55
+
56
+ ## Getting started
57
+
58
+ ### Installation
59
+
60
+ ```sh
61
+ uv add commitizen-spdx-changelog
62
+ # or: pip install commitizen-spdx-changelog
63
+ ```
64
+
65
+ > [!TIP]
66
+ > See the [docs landing page](docs/index.md) for a full overview, and the
67
+ > [usage guide](docs/guide.md) for furher setup and workflow instructions.
68
+
69
+ ### Configuration
70
+
71
+ In `pyproject.toml`:
72
+
73
+ ```toml
74
+ [tool.commitizen]
75
+ changelog_format = "spdx-markdown"
76
+ ```
77
+
78
+ ### Usage
79
+
80
+ ```sh
81
+ cz bump --changelog
82
+ ```
83
+
84
+ The plugin handles changelogs with SPDX frontmatter like:
85
+
86
+ ```markdown
87
+ ---
88
+ # SPDX-FileCopyrightText: 2026 Pablo Hรถrtner <redtux@pm.me>
89
+ #
90
+ # SPDX-License-Identifier: Apache-2.0
91
+
92
+ icon: lucide/git-commit-vertical
93
+ ---
94
+
95
+ # Changelog
96
+
97
+ ## 0.4.0 (2026-06-08)
98
+ ...
99
+ ```
100
+
101
+ ### Development
102
+
103
+ ```sh
104
+ direnv allow
105
+ uv sync --group dev
106
+ ```
107
+
108
+ > [!TIP]
109
+ > Running `direnv allow` will activate the [devbox] environment automatically.
110
+ > See the [Devbox guide](docs/devbox.md) for all available commands and tools.
111
+
112
+ ## Contributing
113
+
114
+ > [!NOTE]
115
+ > Bug reports, feature requests, and pull requests are welcome.
116
+
117
+ - See [docs/contributing.md](docs/contributing.md) for guidelines.
118
+
119
+ For documentation contributions, please follow these principles:
120
+
121
+ Write for humans, keep it minimal, update docs with code, delete dead content.
122
+ Every page in `docs/` and the project `README.md` are held to these standards.
123
+
124
+ ## License
125
+
126
+ Distributed under the terms of the [Apache License 2.0](LICENSE.md).
127
+
128
+ - Copyright ยฉ 2026 Pablo Hรถrtner
129
+
130
+ <!-- References -->
131
+
132
+ [ci-badge]: https://badgen.net/github/checks/redtux/commitizen-spdx-changelog
133
+ [ci-link]: https://github.com/redtux/commitizen-spdx-changelog/actions
134
+ [commitizen]: https://commitizen-tools.github.io/commitizen/
135
+ [devbox]: https://github.com/jetify-com/devbox
136
+ [docusaurus]: https://docusaurus.io/
137
+ [license-badge]: https://badgen.net/github/license/redtux/commitizen-spdx-changelog
138
+ [license-link]: LICENSE.md
139
+ [okf]: https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md
140
+ [pypi-badge]: https://badgen.net/pypi/v/commitizen-spdx-changelog
141
+ [pypi-link]: https://pypi.org/project/commitizen-spdx-changelog/
142
+ [python-badge]: https://badgen.net/pypi/python/commitizen-spdx-changelog
143
+ [release-badge]: https://badgen.net/github/release/redtux/commitizen-spdx-changelog
144
+ [release-link]: https://github.com/redtux/commitizen-spdx-changelog/releases
145
+ [reuse]: https://reuse.software/
146
+ [typing-svg-badge]: https://readme-typing-svg.demolab.com?font=Fira+Code&pause=1000&width=435&lines=SPDX-compliant+Commitizen+Changelogs
147
+ [typing-svg-link]: https://git.io/typing-svg
148
+ [zensical]: https://zensical.org/
@@ -0,0 +1,97 @@
1
+ # SPDX-FileCopyrightText: 2026 Pablo Hรถrtner <redtux@pm.me>
2
+ #
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ # pyproject.toml
6
+ #
7
+ # This file is part of commitizen-spdx-changelog, a plugin
8
+ # for commitizen that generates changelogs in SPDX format.
9
+
10
+ [build-system]
11
+ build-backend = "uv_build"
12
+ requires = ["uv_build>=0.11.21,<0.12.0"]
13
+
14
+ [project]
15
+ authors = [
16
+ { name = "Pablo Hรถrtner", email = "redtux@pm.me" }
17
+ ]
18
+ dependencies = [
19
+ "commitizen>=4.16.3",
20
+ ]
21
+ description = "Commitizen changelog format plugin with YAML frontmatter awareness for REUSE/SPDX-compliant changelogs"
22
+ keywords = ["commitizen", "changelog", "spdx", "reuse", "yaml", "frontmatter"]
23
+ license = "Apache-2.0"
24
+ classifiers = [
25
+ "Development Status :: 3 - Alpha",
26
+ "Intended Audience :: Developers",
27
+ "Programming Language :: Python :: 3",
28
+ "Programming Language :: Python :: 3.13",
29
+ "Programming Language :: Python :: 3.14",
30
+ ]
31
+ name = "commitizen-spdx-changelog"
32
+ readme = "README.md"
33
+ requires-python = ">=3.13"
34
+ version = "0.1.2"
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/redtux/commitizen-spdx-changelog"
38
+ Issues = "https://github.com/redtux/commitizen-spdx-changelog/issues"
39
+ Source = "https://github.com/redtux/commitizen-spdx-changelog"
40
+
41
+ [project.entry-points."commitizen.changelog_format"]
42
+ spdx-markdown = "commitizen_spdx_changelog.formatters.spdx_markdown:SPDXMarkdown"
43
+
44
+ [dependency-groups]
45
+ dev = [
46
+ "mdformat-gfm-alerts>=2.0.0",
47
+ "mdformat-mkdocs[recommended]>=5.1.4",
48
+ "mdformat-pyproject>=0.1.1",
49
+ "mkdocstrings-python>=2.0.5",
50
+ "pytest>=9.1.1",
51
+ "reuse>=6.2.0",
52
+ "rich>=15.0.0",
53
+ "ruff>=0.15.18",
54
+ "ty>=0.0.51",
55
+ "uv>=0.11.24",
56
+ "zensical>=0.0.46",
57
+ ]
58
+
59
+ [tool.commitizen]
60
+ changelog_file = "docs/changelog.md"
61
+ changelog_format = "spdx-markdown"
62
+ changelog_incremental = true
63
+ major_version_zero = true
64
+ name = "cz_conventional_commits"
65
+ post_bump_hooks = ["make uv-lock", "git push --follow-tags"]
66
+ tag_format = "v$version"
67
+ update_changelog_on_bump = true
68
+ version = "0.1.2"
69
+ version_files = [
70
+ "pyproject.toml:version",
71
+ ]
72
+ version_scheme = "semver2"
73
+
74
+ [tool.pyright]
75
+ venvPath = "."
76
+ venv = ".venv"
77
+
78
+ [tool.mdformat]
79
+ exclude = [
80
+ "**/*.env",
81
+ "**/*.json",
82
+ "**/*.jsonc",
83
+ "**/*.lock",
84
+ "**/*.sh",
85
+ "**/*.toml",
86
+ "**/*.yaml",
87
+ "**/*.yml",
88
+ "**/.venv/**",
89
+ "**/LICENSE.md",
90
+ "**/LICENSES/**",
91
+ "**/Makefile",
92
+ "**/node_modules/**",
93
+ "**/out/**",
94
+ "**/tmp/**",
95
+ ]
96
+ number = true
97
+ wrap = 80
@@ -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
+ )