python-kacl 0.7.3__tar.gz → 0.7.4__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.
Files changed (33) hide show
  1. {python_kacl-0.7.3/python_kacl.egg-info → python_kacl-0.7.4}/PKG-INFO +1 -1
  2. {python_kacl-0.7.3 → python_kacl-0.7.4}/kacl/__init__.py +1 -1
  3. {python_kacl-0.7.3 → python_kacl-0.7.4}/kacl/document.py +12 -4
  4. {python_kacl-0.7.3 → python_kacl-0.7.4}/pyproject.toml +1 -1
  5. {python_kacl-0.7.3 → python_kacl-0.7.4/python_kacl.egg-info}/PKG-INFO +1 -1
  6. {python_kacl-0.7.3 → python_kacl-0.7.4}/tests/test_cli.py +28 -0
  7. {python_kacl-0.7.3 → python_kacl-0.7.4}/tests/test_kacl.py +24 -0
  8. {python_kacl-0.7.3 → python_kacl-0.7.4}/LICENSE +0 -0
  9. {python_kacl-0.7.3 → python_kacl-0.7.4}/MANIFEST.in +0 -0
  10. {python_kacl-0.7.3 → python_kacl-0.7.4}/README.md +0 -0
  11. {python_kacl-0.7.3 → python_kacl-0.7.4}/kacl/__main__.py +0 -0
  12. {python_kacl-0.7.3 → python_kacl-0.7.4}/kacl/changes.py +0 -0
  13. {python_kacl-0.7.3 → python_kacl-0.7.4}/kacl/config/kacl-default.yml +0 -0
  14. {python_kacl-0.7.3 → python_kacl-0.7.4}/kacl/config.py +0 -0
  15. {python_kacl-0.7.3 → python_kacl-0.7.4}/kacl/element.py +0 -0
  16. {python_kacl-0.7.3 → python_kacl-0.7.4}/kacl/exception.py +0 -0
  17. {python_kacl-0.7.3 → python_kacl-0.7.4}/kacl/jira_client.py +0 -0
  18. {python_kacl-0.7.3 → python_kacl-0.7.4}/kacl/kacl_cli.py +0 -0
  19. {python_kacl-0.7.3 → python_kacl-0.7.4}/kacl/link_provider.py +0 -0
  20. {python_kacl-0.7.3 → python_kacl-0.7.4}/kacl/parser.py +0 -0
  21. {python_kacl-0.7.3 → python_kacl-0.7.4}/kacl/serializer.py +0 -0
  22. {python_kacl-0.7.3 → python_kacl-0.7.4}/kacl/utils.py +0 -0
  23. {python_kacl-0.7.3 → python_kacl-0.7.4}/kacl/validation.py +0 -0
  24. {python_kacl-0.7.3 → python_kacl-0.7.4}/kacl/version.py +0 -0
  25. {python_kacl-0.7.3 → python_kacl-0.7.4}/python_kacl.egg-info/SOURCES.txt +0 -0
  26. {python_kacl-0.7.3 → python_kacl-0.7.4}/python_kacl.egg-info/dependency_links.txt +0 -0
  27. {python_kacl-0.7.3 → python_kacl-0.7.4}/python_kacl.egg-info/entry_points.txt +0 -0
  28. {python_kacl-0.7.3 → python_kacl-0.7.4}/python_kacl.egg-info/not-zip-safe +0 -0
  29. {python_kacl-0.7.3 → python_kacl-0.7.4}/python_kacl.egg-info/requires.txt +0 -0
  30. {python_kacl-0.7.3 → python_kacl-0.7.4}/python_kacl.egg-info/top_level.txt +0 -0
  31. {python_kacl-0.7.3 → python_kacl-0.7.4}/requirements.txt +0 -0
  32. {python_kacl-0.7.3 → python_kacl-0.7.4}/setup.cfg +0 -0
  33. {python_kacl-0.7.3 → python_kacl-0.7.4}/tests/test_cli_workflow.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-kacl
3
- Version: 0.7.3
3
+ Version: 0.7.4
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
@@ -1,5 +1,5 @@
1
1
  # Version of the python-kacl package
2
- __version__ = "0.7.3"
2
+ __version__ = "0.7.4"
3
3
 
4
4
  from kacl.document import KACLDocument
5
5
  from kacl.serializer import KACLMarkdownSerializer
@@ -30,7 +30,7 @@ class KACLDocument:
30
30
  link_references=None,
31
31
  meta_data=None,
32
32
  file_path=None,
33
- config=KACLConfig(),
33
+ config=None,
34
34
  ):
35
35
  self.__data = data
36
36
  self.__headers = headers if headers else []
@@ -39,7 +39,7 @@ class KACLDocument:
39
39
  if not self.__link_references:
40
40
  self.__link_references = dict()
41
41
  self.__meta_data = meta_data
42
- self.config = config
42
+ self.config = config if config is not None else KACLConfig()
43
43
  self.stash = []
44
44
  self.file_path = file_path
45
45
 
@@ -82,6 +82,9 @@ class KACLDocument:
82
82
  data = fh.read()
83
83
  try:
84
84
  doc = KACLDocument.parse(data, None)
85
+ # stash documents must be validated against the same
86
+ # config as the changelog they belong to
87
+ doc.config = self.config
85
88
  self.stash.append(doc)
86
89
  except Exception:
87
90
  continue
@@ -205,7 +208,7 @@ class KACLDocument:
205
208
  try:
206
209
  v0 = versions[i]
207
210
  v1 = versions[i + 1]
208
- if semver.compare(v0.version(), v1.version()) < 1:
211
+ if semver.Version.parse(v0.version()).compare(v1.version()) < 1:
209
212
  validation.add_error(
210
213
  line=v1.raw(),
211
214
  line_number=v1.line_number(),
@@ -619,7 +622,12 @@ class KACLDocument:
619
622
  versions[i].set_link(link_provider.unreleased_changes(**fargs))
620
623
  else:
621
624
  versions[i].set_link(link_provider.compare_versions(**fargs))
622
- versions[-1].set_link(link_provider.initial_version(**fargs))
625
+ versions[-1].set_link(
626
+ link_provider.initial_version(
627
+ version=versions[-1].version(),
628
+ latest_version=self.current_version(),
629
+ )
630
+ )
623
631
  elif len(versions) == 1:
624
632
  fargs = {
625
633
  "version": versions[0].version(),
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "python-kacl"
7
- version = "0.7.3"
7
+ version = "0.7.4"
8
8
  description = "Python module and CLI tool for validating and modifying Changelogs in \"keep-a-changelog\" format\""
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-kacl
3
- Version: 0.7.3
3
+ Version: 0.7.4
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
@@ -20,6 +20,34 @@ def test_verify():
20
20
  assert result.exit_code == 11 # spawns 11 errors
21
21
 
22
22
 
23
+ def test_verify_stash_with_custom_sections(tmp_path):
24
+ """Stash files must be validated against the loaded config, not the built-in defaults."""
25
+ runner = CliRunner()
26
+ resources_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data/")
27
+ changelog_file = os.path.join(resources_dir, "CHANGELOG.md")
28
+ stash_dir_local = os.path.join(resources_dir, "stash-custom-section")
29
+ config_file = os.path.join(resources_dir, "custom-sections-config.yml")
30
+
31
+ with runner.isolated_filesystem(temp_dir=tmp_path) as project_root_path:
32
+ shutil.copyfile(changelog_file, os.path.join(project_root_path, "CHANGELOG.md"))
33
+ shutil.copytree(stash_dir_local, os.path.join(project_root_path, ".kacl_stash"))
34
+
35
+ # without the custom config the stashed "Chore" section is rejected
36
+ result = runner.invoke(
37
+ cli, ["-f", "CHANGELOG.md", "verify"], catch_exceptions=False
38
+ )
39
+ assert result.exit_code != 0, result.output
40
+ assert '"Chore" is not a valid section' in result.output
41
+
42
+ # with a config that allows "Chore" the stashed changes must validate
43
+ result = runner.invoke(
44
+ cli,
45
+ ["-c", config_file, "-f", "CHANGELOG.md", "verify"],
46
+ catch_exceptions=False,
47
+ )
48
+ assert result.exit_code == 0, result.output
49
+
50
+
23
51
  def test_verify_invalid_duplicates():
24
52
  runner = CliRunner()
25
53
  result = runner.invoke(
@@ -427,6 +427,30 @@ class TestKacl(TestCase):
427
427
  for v in versions:
428
428
  self.assertIsNotNone(v.link())
429
429
 
430
+ def test_link_generation_initial_version(self):
431
+ changelog_file = os.path.join(
432
+ os.path.dirname(os.path.realpath(__file__)), "data", "CHANGELOG.md"
433
+ )
434
+ changelog = kacl.load(changelog_file)
435
+ host_url = "https://github.com/user/repository"
436
+ changelog.generate_links(host_url=host_url)
437
+
438
+ versions = changelog.versions()
439
+
440
+ # the oldest version has to link to its own tag, not the penultimate one
441
+ initial_version = versions[-1]
442
+ self.assertEqual(
443
+ initial_version.link(),
444
+ f"{host_url}/tree/{initial_version.version()}",
445
+ )
446
+
447
+ # every version in between has to compare against its predecessor
448
+ for i in range(1, len(versions) - 1):
449
+ self.assertEqual(
450
+ versions[i].link(),
451
+ f"{host_url}/compare/{versions[i + 1].version()}...{versions[i].version()}",
452
+ )
453
+
430
454
 
431
455
  def test_squash(tmp_path, snapshot):
432
456
  changelog_file = os.path.join(
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes