python-kacl 0.7.6__py3-none-any.whl → 0.7.7__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.
kacl/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  # Version of the python-kacl package
2
- __version__ = "0.7.6"
2
+ __version__ = "0.7.7"
3
3
 
4
4
  from kacl.document import KACLDocument
5
5
  from kacl.serializer import KACLMarkdownSerializer
kacl/document.py CHANGED
@@ -229,10 +229,11 @@ class KACLDocument:
229
229
  pass
230
230
 
231
231
  # 4 link references
232
- # 4.1 check that there are only linked references
233
- version_strings = [v.version().lower() for v in versions]
234
- for v, link in self.__link_references.items():
235
- if v.lower() not in version_strings:
232
+ # 4.1 check that every reference is either a version link or is used
233
+ # inside of the changelog (e.g. "[!1234]" pointing to a merge request)
234
+ content = self._referencable_content().lower()
235
+ for link in self.extra_link_references():
236
+ if f"[{link.title().lower()}]" not in content:
236
237
  validation.add_error(
237
238
  line=link.raw(),
238
239
  line_number=link.line_number(),
@@ -243,6 +244,27 @@ class KACLDocument:
243
244
 
244
245
  return validation
245
246
 
247
+ def extra_link_references(self):
248
+ """Returns all link references that do not belong to a version."""
249
+ version_strings = [v.version().lower() for v in self.__versions]
250
+ return [
251
+ link
252
+ for label, link in self.__link_references.items()
253
+ if label.lower() not in version_strings
254
+ ]
255
+
256
+ def _referencable_content(self):
257
+ """Returns the text of all versions in which link references can be used."""
258
+ parts = []
259
+ for v in self.__versions:
260
+ parts.append(v.body() or "")
261
+ try:
262
+ for changes in v.sections().values():
263
+ parts.extend(changes.items())
264
+ except ValueError:
265
+ pass
266
+ return "\n".join(parts)
267
+
246
268
  def is_valid(self):
247
269
  """Checks if the current changelog is valid
248
270
  Returns:
@@ -289,6 +311,8 @@ class KACLDocument:
289
311
  else:
290
312
  change = f"[{v.version()}] {change}"
291
313
  squash_version.add(section, change)
314
+ # the squashed version is gone, so is its link reference
315
+ self.__link_references.pop(v.version().lower(), None)
292
316
 
293
317
  versions_unsquashed.append(squash_version)
294
318
  versions_unsquashed.sort(reverse=True)
kacl/serializer.py CHANGED
@@ -30,6 +30,10 @@ class KACLMarkdownSerializer:
30
30
  if version.has_link_reference():
31
31
  link_references.append(self.__serialize_link_reference(version))
32
32
 
33
+ # keep references that do not belong to a version (e.g. merge requests)
34
+ for link in document.extra_link_references():
35
+ link_references.append(f"[{link.title()}]: {link.body()}")
36
+
33
37
  elif isinstance(document, KACLVersion):
34
38
  data.extend([self.__serialize_version(document), ""])
35
39
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-kacl
3
- Version: 0.7.6
3
+ Version: 0.7.7
4
4
  Summary: Python module and CLI tool for validating and modifying Changelogs in "keep-a-changelog" format"
5
5
  Author-email: Matthias Schmieder <schmieder.matthias@gmail.com>
6
6
  License: MIT
@@ -56,6 +56,7 @@ A tool for verifying and modifying changelog in the [**K**eep-**A-C**hange-**L**
56
56
  - [Workflow Integration](#workflow-integration)
57
57
  - [Benefits](#benefits)
58
58
  - [Link Generation](#link-generation)
59
+ - [Custom Link References](#custom-link-references)
59
60
  - [Squashing releases](#squashing-releases)
60
61
  - [Example](#example)
61
62
  - [Issue Management Integration](#issue-management-integration)
@@ -778,6 +779,25 @@ kacl:
778
779
 
779
780
  Using the python format syntax you can generate any links you want. The available replacement variables are `version`, `previous_version`, `host` and `latest_version`.
780
781
 
782
+ ### Custom Link References
783
+
784
+ Besides version links, you can use your own link references in changelog entries, for example to link to merge requests or issues. A reference is accepted as long as `[label]` is used in at least one entry:
785
+
786
+ ```markdown
787
+ ## [1.0.0] - 2026-04-10
788
+
789
+ ### Changed
790
+
791
+ - a big change ([!1234])
792
+
793
+ [1.0.0]: https://gitlab.com/my/repo/-/tags/v1.0.0
794
+ [!1234]: https://gitlab.com/my/repo/-/merge_requests/1234
795
+ ```
796
+
797
+ - `kacl-cli verify` reports references that are never used with `Link not referenced anywhere in the document`.
798
+ - Custom references are preserved when `kacl-cli` rewrites the changelog (`add`, `release`, ...). They are written after the version links.
799
+ - `kacl-cli squash` removes the references of the squashed versions.
800
+
781
801
  ## Squashing releases
782
802
 
783
803
  If you are follwing a automated versioning approach, you will often times create a number of versions that might clutter Changelog. For this purpose, `kacl-cli` provides a `squash` command that let's you squash releases into a single one without loosing valuable information.
@@ -1,22 +1,22 @@
1
- kacl/__init__.py,sha256=TSKqPUQPsZJN1hgqqbXv4rRZl2vA0GBEhQFvsmfzHtw,667
1
+ kacl/__init__.py,sha256=7gjIG9nyG7Y0PfI8dPh73XnYtnzRut358actaFEi3j4,667
2
2
  kacl/__main__.py,sha256=cpulIGoFUJNN5ZW9oUoNN1PnBvrOyJ24xwtpf_yRwgQ,91
3
3
  kacl/changes.py,sha256=Speu1KLMNQVn0U2BMaO8ta4IEaQLTQtpW0IhN0JjGdY,704
4
4
  kacl/config.py,sha256=c2QiP-BriJJwzrw36oigJWKe6t4o6yhmN_nPSL6bcRk,4242
5
- kacl/document.py,sha256=4BGvRpbr5JxMRoBPuN_oGTjVNTyjHFcl-xB4rhjEOIY,31767
5
+ kacl/document.py,sha256=SasVN1iXmE7q-hfFZpifKLXiyTjX8qF2Qwu1B63eAhc,32760
6
6
  kacl/element.py,sha256=OG02QI8ND5fJpBMceT6dbIHr4uX9gLxK_fPCsOvMDHI,416
7
7
  kacl/exception.py,sha256=MfOVpUvhcQtm10rSY__74-oLo445PG8mLFGJPPIfXH0,41
8
8
  kacl/jira_client.py,sha256=KPE94bZDkJFKw3okFsCgf2DjoyMlUUTMZKtQGKreVQY,989
9
9
  kacl/kacl_cli.py,sha256=LzwnB990BpwL5nrKi4EbeDSWuT_CMd4rdqo6kTrlARw,24184
10
10
  kacl/link_provider.py,sha256=tgvMYhJe2ErH1m_qXMlQEacq9Cg_KGp_-sF03sVFP6E,1866
11
11
  kacl/parser.py,sha256=EUtRjgaW0beWVqiYaRJ9Rcf6jbuGoTgWzVBdOdUHnv8,2587
12
- kacl/serializer.py,sha256=g5eFim8OpSbgyShyFANSwOEbAfJqCNUXaRJtPO79blc,3931
12
+ kacl/serializer.py,sha256=bNLlcdu-Pkd9IfDphjQaE-iqcos92Yy82ReuvJ91fZw,4149
13
13
  kacl/utils.py,sha256=4iWIJVNtv22v0IGXDjuEATPMQsJBr5Ycy9Q2zV2jkHE,2835
14
14
  kacl/validation.py,sha256=b9r_5CyY6Cmi9BePh47IgZ3j64zdVsoB_fFvucieNbw,2125
15
15
  kacl/version.py,sha256=Rh0DpHqjrkoPhemWEzRMu11U7DY1f8PvCh30zwggF5I,10692
16
16
  kacl/config/kacl-default.yml,sha256=cXHl_w04SW0HA7OyJMMuaC6DTeXlhI2Sfsx7lygTPf4,1513
17
- python_kacl-0.7.6.dist-info/licenses/LICENSE,sha256=TRSJOIt7LZuMeZXFleJVL_LHczSxqi70HEiTLT-kI8Q,1075
18
- python_kacl-0.7.6.dist-info/METADATA,sha256=4zMhPmNR_e0v0xOFoRZ8wh4r_yN_mwKmSUU9tPuSZ8E,42453
19
- python_kacl-0.7.6.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
20
- python_kacl-0.7.6.dist-info/entry_points.txt,sha256=rXqqJKfm6Y7fYfioq_7ay2VWOOM9C-hts1IsoGTtojM,76
21
- python_kacl-0.7.6.dist-info/top_level.txt,sha256=BcmQgo67JyGnVZ3Jc0Ag8hKMGVOqXc8ex01zW4Njw5M,5
22
- python_kacl-0.7.6.dist-info/RECORD,,
17
+ python_kacl-0.7.7.dist-info/licenses/LICENSE,sha256=TRSJOIt7LZuMeZXFleJVL_LHczSxqi70HEiTLT-kI8Q,1075
18
+ python_kacl-0.7.7.dist-info/METADATA,sha256=Y-pZnC2OxToMI6lO5ix4FjjXzlBak747--wO1uKqM1U,43256
19
+ python_kacl-0.7.7.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
20
+ python_kacl-0.7.7.dist-info/entry_points.txt,sha256=rXqqJKfm6Y7fYfioq_7ay2VWOOM9C-hts1IsoGTtojM,76
21
+ python_kacl-0.7.7.dist-info/top_level.txt,sha256=BcmQgo67JyGnVZ3Jc0Ag8hKMGVOqXc8ex01zW4Njw5M,5
22
+ python_kacl-0.7.7.dist-info/RECORD,,