python-kacl 0.7.5__tar.gz → 0.7.6__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.
- {python_kacl-0.7.5/python_kacl.egg-info → python_kacl-0.7.6}/PKG-INFO +1 -1
- {python_kacl-0.7.5 → python_kacl-0.7.6}/kacl/__init__.py +1 -1
- {python_kacl-0.7.5 → python_kacl-0.7.6}/kacl/version.py +34 -4
- {python_kacl-0.7.5 → python_kacl-0.7.6}/pyproject.toml +1 -1
- {python_kacl-0.7.5 → python_kacl-0.7.6/python_kacl.egg-info}/PKG-INFO +1 -1
- {python_kacl-0.7.5 → python_kacl-0.7.6}/tests/test_kacl.py +23 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/LICENSE +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/MANIFEST.in +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/README.md +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/kacl/__main__.py +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/kacl/changes.py +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/kacl/config/kacl-default.yml +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/kacl/config.py +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/kacl/document.py +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/kacl/element.py +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/kacl/exception.py +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/kacl/jira_client.py +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/kacl/kacl_cli.py +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/kacl/link_provider.py +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/kacl/parser.py +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/kacl/serializer.py +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/kacl/utils.py +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/kacl/validation.py +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/python_kacl.egg-info/SOURCES.txt +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/python_kacl.egg-info/dependency_links.txt +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/python_kacl.egg-info/entry_points.txt +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/python_kacl.egg-info/not-zip-safe +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/python_kacl.egg-info/requires.txt +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/python_kacl.egg-info/top_level.txt +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/requirements.txt +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/setup.cfg +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/tests/test_cli.py +0 -0
- {python_kacl-0.7.5 → python_kacl-0.7.6}/tests/test_cli_workflow.py +0 -0
|
@@ -105,6 +105,24 @@ class KACLVersion(KACLElement):
|
|
|
105
105
|
self.__sections[sec.title()] = sec
|
|
106
106
|
return self.__sections
|
|
107
107
|
|
|
108
|
+
def duplicate_sections(self):
|
|
109
|
+
"""Returns every section element whose title was already used earlier in this version."""
|
|
110
|
+
if not self.body().strip():
|
|
111
|
+
return []
|
|
112
|
+
|
|
113
|
+
seen = set()
|
|
114
|
+
duplicates = []
|
|
115
|
+
for section in KACLParser.parse_header(
|
|
116
|
+
text=self.body(),
|
|
117
|
+
start_depth=3,
|
|
118
|
+
end_depth=3,
|
|
119
|
+
line_offset=self.line_number(),
|
|
120
|
+
):
|
|
121
|
+
if section.title() in seen:
|
|
122
|
+
duplicates.append(section)
|
|
123
|
+
seen.add(section.title())
|
|
124
|
+
return duplicates
|
|
125
|
+
|
|
108
126
|
def changes(self, section):
|
|
109
127
|
sections = self.sections()
|
|
110
128
|
if sections and section in sections:
|
|
@@ -200,11 +218,23 @@ class KACLVersion(KACLElement):
|
|
|
200
218
|
try:
|
|
201
219
|
sections = self.sections()
|
|
202
220
|
except ValueError as e:
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
221
|
+
duplicates = self.duplicate_sections()
|
|
222
|
+
if not duplicates:
|
|
223
|
+
errors.append(
|
|
224
|
+
KACLValidationError(
|
|
225
|
+
error_message=str(e), line_number=self.line_number()
|
|
226
|
+
)
|
|
227
|
+
)
|
|
228
|
+
for duplicate in duplicates:
|
|
229
|
+
errors.append(
|
|
230
|
+
KACLValidationError(
|
|
231
|
+
line=duplicate.raw(),
|
|
232
|
+
line_number=duplicate.line_number(),
|
|
233
|
+
error_message=f"Version '{self.version()}' has multiple sections with title '{duplicate.title()}'",
|
|
234
|
+
start_character_pos=0,
|
|
235
|
+
end_character_pos=len(duplicate.raw()),
|
|
236
|
+
)
|
|
206
237
|
)
|
|
207
|
-
)
|
|
208
238
|
return errors
|
|
209
239
|
|
|
210
240
|
for title, element in sections.items():
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "python-kacl"
|
|
7
|
-
version = "0.7.
|
|
7
|
+
version = "0.7.6"
|
|
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"
|
|
@@ -657,3 +657,26 @@ def test_release_no_unreleased_multiple_versions(tmp_path):
|
|
|
657
657
|
second_version_after = versions_after[1]
|
|
658
658
|
# The link might be updated during auto-link, but shouldn't be broken
|
|
659
659
|
assert second_version_after.link() is not None
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
def test_validate_reports_every_duplicated_section():
|
|
663
|
+
changelog = kacl.parse(
|
|
664
|
+
"# Changelog\n\n"
|
|
665
|
+
"All notable changes to this project will be documented in this file.\n\n"
|
|
666
|
+
"The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), "
|
|
667
|
+
"and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n\n"
|
|
668
|
+
"## [Unreleased]\n\n"
|
|
669
|
+
"### Added\n\n- a\n\n"
|
|
670
|
+
"### Changed\n\n- b\n\n"
|
|
671
|
+
"### Added\n\n- a again\n\n"
|
|
672
|
+
"### Changed\n\n- b again\n\n"
|
|
673
|
+
)
|
|
674
|
+
errors = [
|
|
675
|
+
e
|
|
676
|
+
for e in changelog.validate().errors()
|
|
677
|
+
if "multiple sections" in e.error_message()
|
|
678
|
+
]
|
|
679
|
+
assert [(e.line_number(), e.line()) for e in errors] == [
|
|
680
|
+
(17, "### Added"),
|
|
681
|
+
(21, "### Changed"),
|
|
682
|
+
]
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|