conf: fix wrong indentation for Patch files listed as extra-patches

This commit is contained in:
Fabio Valentini 2024-06-04 17:38:28 +02:00
parent e644640229
commit 1ff3e433a4
No known key found for this signature in database
GPG key ID: 5AC5F572E5D410AF
2 changed files with 37 additions and 5 deletions

View file

@ -1,3 +1,10 @@
Unreleased
==========
Fixed:
- The off-by-one indent error for files listed as `extra-patches` was fixed.
Version 26.1.1
==============

View file

@ -512,7 +512,7 @@ def conf_comments_to_spec_comments(comments: Optional[list[str]]) -> list[str]:
return lines
class SourceOrPatch:
class Source:
def __init__(self, data: dict):
self._data = data
@ -537,6 +537,31 @@ class SourceOrPatch:
return " " * (16 - (len("Source") + len(str(self.number)) + 1))
class Patch:
def __init__(self, data: dict):
self._data = data
@property
def file(self) -> str:
return self._data["file"]
@property
def number(self) -> int:
return self._data["number"]
@property
def comments(self) -> list[str]:
return self._data.get("comments") or list()
@property
def comment_lines(self) -> list[str]:
return conf_comments_to_spec_comments(self.comments)
@property
def whitespace(self) -> str:
return " " * (16 - (len("Patch") + len(str(self.number)) + 1))
class TomlConf:
def __init__(self, data: Optional[dict] = None):
self._data = data or dict()
@ -629,20 +654,20 @@ class TomlConf:
return conf_comments_to_spec_comments(self.package_cargo_toml_patch_comments)
@property
def package_extra_sources(self) -> Optional[list[SourceOrPatch]]:
def package_extra_sources(self) -> Optional[list[Source]]:
if package := self._package:
if sources := package.get("extra-sources"):
return [SourceOrPatch(source) for source in sources]
return [Source(source) for source in sources]
else:
return None
else:
return None
@property
def package_extra_patches(self) -> Optional[list[SourceOrPatch]]:
def package_extra_patches(self) -> Optional[list[Patch]]:
if package := self._package:
if patches := package.get("extra-patches"):
return [SourceOrPatch(patch) for patch in patches]
return [Patch(patch) for patch in patches]
else:
return None
else: