python-kacl 0.6.2__py3-none-any.whl → 0.6.4__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.6.2"
2
+ __version__ = "0.6.4"
3
3
 
4
4
  from kacl.document import KACLDocument
5
5
  from kacl.serializer import KACLMarkdownSerializer
kacl/document.py CHANGED
@@ -665,6 +665,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
665
665
  "ERROR: Could not determine project url. Update your config or run within a valid git repository"
666
666
  )
667
667
 
668
+ host_url = host_url.removesuffix(".git")
669
+
668
670
  return LinkProvider(
669
671
  host_url=host_url,
670
672
  compare_versions_template=compare_versions_template,
kacl/kacl_cli.py CHANGED
@@ -177,7 +177,12 @@ def next(ctx, version):
177
177
  @cli.command()
178
178
  @click.pass_context
179
179
  @click.argument("version", type=str)
180
- def get(ctx, version):
180
+ @click.option(
181
+ "--no-link",
182
+ is_flag=True,
183
+ help="This option suppresses a link, even if available.",
184
+ )
185
+ def get(ctx, version, no_link):
181
186
  """Returns a given version from the Changelog."""
182
187
  kacl_changelog = load_changelog(ctx)
183
188
 
@@ -185,6 +190,8 @@ def get(ctx, version):
185
190
  kacl_version = kacl_changelog.get(version)
186
191
 
187
192
  if kacl_version:
193
+ if no_link:
194
+ kacl_version.set_link(None)
188
195
  kacl_changelog_content = kacl.dump(kacl_version)
189
196
  click.echo(kacl_changelog_content)
190
197
  else:
kacl/serializer.py CHANGED
@@ -11,9 +11,9 @@ class KACLMarkdownSerializer:
11
11
  pass
12
12
 
13
13
  def serialize(self, document):
14
+ data = []
15
+ link_references = []
14
16
  if isinstance(document, KACLDocument):
15
- data = []
16
-
17
17
  serialized_metadata = self.__serialize_metadata(document.metadata())
18
18
  if serialized_metadata:
19
19
  data.extend(serialized_metadata)
@@ -21,20 +21,23 @@ class KACLMarkdownSerializer:
21
21
  data.append(self.__serialize_header(document.header()))
22
22
  data.append(document.header().body())
23
23
 
24
- link_references = []
25
24
  for version in document.versions():
26
25
  data.extend([self.__serialize_version(version), ""])
27
26
  if version.has_link_reference():
28
27
  link_references.append(self.__serialize_link_reference(version))
29
28
 
30
- data.extend(link_references)
29
+ elif isinstance(document, KACLVersion):
30
+ data.extend([self.__serialize_version(document), ""])
31
31
 
32
- if data[-1] != "":
33
- data.append("")
32
+ if document.has_link_reference():
33
+ link_references.append(self.__serialize_link_reference(document))
34
34
 
35
- return "\n".join(data)
36
- elif isinstance(document, KACLVersion):
37
- return self.__serialize_version(document)
35
+ data.extend(link_references)
36
+
37
+ if data[-1] != "":
38
+ data.append("")
39
+
40
+ return "\n".join(data)
38
41
 
39
42
  def __serialize_metadata(self, metadata):
40
43
  if not metadata:
kacl/version.py CHANGED
@@ -47,9 +47,9 @@ class KACLVersion(KACLElement):
47
47
  return self.__link_reference.body()
48
48
 
49
49
  def set_link(self, link):
50
- if isinstance(link, KACLElement):
50
+ if not link or isinstance(link, KACLElement):
51
51
  self.__link_reference = link
52
- elif link is not None:
52
+ else:
53
53
  self.__link_reference = KACLElement(title=self.version(), body=link)
54
54
 
55
55
  def has_link_reference(self):
@@ -149,7 +149,7 @@ class KACLVersion(KACLElement):
149
149
  line_number=self.line_number(),
150
150
  start_character_pos=start_pos,
151
151
  end_character_pos=end_pos,
152
- error_message=")Version is not a valid semantic version.",
152
+ error_message="Version is not a valid semantic version.",
153
153
  )
154
154
  )
155
155
  return errors
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: python-kacl
3
- Version: 0.6.2
3
+ Version: 0.6.4
4
4
  Summary: Python module and CLI tool for validating and modifying Changelogs in "keep-a-changelog" format"
5
5
  Home-page: https://gitlab.com/schmieder.matthias/python-kacl.git
6
6
  Author: Matthias Schmieder
@@ -19,6 +19,17 @@ Requires-Dist: semver
19
19
  Requires-Dist: gitpython
20
20
  Requires-Dist: pyyaml
21
21
  Requires-Dist: jira
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: description-content-type
27
+ Dynamic: home-page
28
+ Dynamic: license
29
+ Dynamic: license-file
30
+ Dynamic: requires-dist
31
+ Dynamic: requires-python
32
+ Dynamic: summary
22
33
 
23
34
  # python-kacl
24
35
 
@@ -1,26 +1,26 @@
1
- kacl/__init__.py,sha256=vqGuRh20S5vuEY83cWbWkhGIWtSBBdvK-Fw4Z_Bzjuk,644
1
+ kacl/__init__.py,sha256=q8SmFU-sgBzWA5PVrCnpP_Bb1gmCSKi3grD6o4TcEmw,644
2
2
  kacl/__main__.py,sha256=cpulIGoFUJNN5ZW9oUoNN1PnBvrOyJ24xwtpf_yRwgQ,91
3
3
  kacl/changes.py,sha256=A0POz-xFMpFuq7nISnx_K75xOZOMmBuHq6EZ8NOQDsU,661
4
4
  kacl/config.py,sha256=Glw-1hRqS3AHpZ-2QRGzHRQ-TSLc1xtneb2MEATWFEQ,3966
5
- kacl/document.py,sha256=5QHR0-kkO-wvjwX6kaQC-NzGe13sVqdBThGa_V3XQLA,24687
5
+ kacl/document.py,sha256=dzeYCIgLA1WzK04jeeCW_AYSOCampc9x2cAHdbnEMpY,24737
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
- kacl/kacl_cli.py,sha256=fdTVlhjldQGBRhiSG5x9SnnwKTgysLxhqlkjx8BUSK8,19804
9
+ kacl/kacl_cli.py,sha256=KeCT4DydkHjckt5sbTtTwp2BQf0RllXpBUwLj-G5-U0,19987
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=4HU0G6ETbsvf6TbuRdhuNcuWFfifMT6jAEyhtJkAL8s,2734
12
+ kacl/serializer.py,sha256=VkPuW06-ehaHsNRtskLJ7o-l3Ckgs8oONkgxceewrms,2851
13
13
  kacl/utils.py,sha256=bHiDDmjoYB868Bm732vNjpfML-6xcNQQqS7NQn_Sfm0,2824
14
14
  kacl/validation.py,sha256=b9r_5CyY6Cmi9BePh47IgZ3j64zdVsoB_fFvucieNbw,2125
15
- kacl/version.py,sha256=OooYgbCgH6p0fYPOlU_V-I1pwnCVgLSZ2uOg2gjaogw,9532
15
+ kacl/version.py,sha256=IDYCWIIXzxdYyMptUAidMgf0SXJqoETFVJ8NVyKgA9A,9526
16
16
  kacl/config/kacl-default.yml,sha256=BdrQytOsx32_vXXBtR3VRp1-nzWrczNVc-gHuCGYuIA,1424
17
+ python_kacl-0.6.4.dist-info/licenses/LICENSE,sha256=TRSJOIt7LZuMeZXFleJVL_LHczSxqi70HEiTLT-kI8Q,1075
17
18
  tests/__init__.py,sha256=dwb12vsojIwrtIgqwjc2fWhEVgVoiedUaVpZ7kusfY0,23
18
19
  tests/snapshot_directory.py,sha256=yH_ZpzJG5nA6F1ZxCrFPpbxBBON6bxSYO5OYZqKuzZA,1264
19
- tests/test_cli.py,sha256=Fc8DA_72cYyjXQm9AfJdAzz89D5zVJGInIxwIBhqrKA,14286
20
+ tests/test_cli.py,sha256=C4dMCJo-lq6rs5euIJdM55Bvm9YGKot_a36FO8YCtWU,17006
20
21
  tests/test_kacl.py,sha256=7hxrBVnj2srkhJGVrfpt651QEItthq-iDntxGnEbt_g,15919
21
- python_kacl-0.6.2.dist-info/LICENSE,sha256=TRSJOIt7LZuMeZXFleJVL_LHczSxqi70HEiTLT-kI8Q,1075
22
- python_kacl-0.6.2.dist-info/METADATA,sha256=U0oSV6yMNH8pewfV9dwoQeq2DhZlF7fNnEIGuWEB3Lg,24089
23
- python_kacl-0.6.2.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
24
- python_kacl-0.6.2.dist-info/entry_points.txt,sha256=8oCwuEyBEH-Z1M_xZIUePgfM7HfkYUAwcXdTPdrnwt4,49
25
- python_kacl-0.6.2.dist-info/top_level.txt,sha256=25gO0j-S3j_-DCptjHqVBlJi3tH_tiN8qyympi1E_Ys,11
26
- python_kacl-0.6.2.dist-info/RECORD,,
22
+ python_kacl-0.6.4.dist-info/METADATA,sha256=hC3mJKWO71afeUGCM_hlHL7cRL1AVAGO7WZQ-c8_JGs,24325
23
+ python_kacl-0.6.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
+ python_kacl-0.6.4.dist-info/entry_points.txt,sha256=8oCwuEyBEH-Z1M_xZIUePgfM7HfkYUAwcXdTPdrnwt4,49
25
+ python_kacl-0.6.4.dist-info/top_level.txt,sha256=25gO0j-S3j_-DCptjHqVBlJi3tH_tiN8qyympi1E_Ys,11
26
+ python_kacl-0.6.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.2.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
tests/test_cli.py CHANGED
@@ -416,3 +416,77 @@ def test_add_comments(tmp_path):
416
416
  catch_exceptions=False,
417
417
  )
418
418
  assert result.exit_code == 0, result.output
419
+
420
+
421
+ @freeze_time("2023-01-01")
422
+ def test_get_no_link_available(tmp_path, snapshot):
423
+ runner = CliRunner()
424
+ resources_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data/")
425
+ changelog_file = os.path.join(resources_dir, "CHANGELOG_missing_link.md")
426
+
427
+ with runner.isolated_filesystem(temp_dir=tmp_path) as project_root_path:
428
+ result = runner.invoke(
429
+ cli,
430
+ [
431
+ "-c",
432
+ os.path.join(resources_dir, "extension-config.yml"),
433
+ "-f",
434
+ changelog_file,
435
+ "get",
436
+ "2.0.0",
437
+ ],
438
+ catch_exceptions=False,
439
+ )
440
+ assert result.exit_code == 0, result.output
441
+ with open(os.path.join(project_root_path, "output.md"), "w") as file:
442
+ file.write(result.output)
443
+ snapshot_directory(snapshot=snapshot, directory_path=project_root_path)
444
+
445
+
446
+ def test_get_link_available(tmp_path, snapshot):
447
+ runner = CliRunner()
448
+ resources_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data/")
449
+ changelog_file = os.path.join(resources_dir, "CHANGELOG_missing_link.md")
450
+
451
+ with runner.isolated_filesystem(temp_dir=tmp_path) as project_root_path:
452
+ result = runner.invoke(
453
+ cli,
454
+ [
455
+ "-c",
456
+ os.path.join(resources_dir, "extension-config.yml"),
457
+ "-f",
458
+ changelog_file,
459
+ "get",
460
+ "1.0.0",
461
+ ],
462
+ catch_exceptions=False,
463
+ )
464
+ assert result.exit_code == 0, result.output
465
+ with open(os.path.join(project_root_path, "output.md"), "w") as file:
466
+ file.write(result.output)
467
+ snapshot_directory(snapshot=snapshot, directory_path=project_root_path)
468
+
469
+
470
+ def test_get_suppress_available_link(tmp_path, snapshot):
471
+ runner = CliRunner()
472
+ resources_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data/")
473
+ changelog_file = os.path.join(resources_dir, "CHANGELOG_missing_link.md")
474
+
475
+ with runner.isolated_filesystem(temp_dir=tmp_path) as project_root_path:
476
+ result = runner.invoke(
477
+ cli,
478
+ [
479
+ "-c",
480
+ os.path.join(resources_dir, "extension-config.yml"),
481
+ "-f",
482
+ changelog_file,
483
+ "get",
484
+ "--no-link",
485
+ "1.0.0",
486
+ ],
487
+ catch_exceptions=False,
488
+ )
489
+ assert result.exit_code == 0, result.output
490
+ with open(os.path.join(project_root_path, "output.md"), "w") as file:
491
+ file.write(result.output)
492
+ snapshot_directory(snapshot=snapshot, directory_path=project_root_path)