diff --git a/CHANGELOG.md b/CHANGELOG.md index de56ac5..a8dd0bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +Unreleased +========== + +Fixed: + +- The off-by-one indent error for files listed as `extra-patches` was fixed. + Version 26.1.1 ============== diff --git a/rust2rpm/conf.py b/rust2rpm/conf.py index c13e730..b643174 100644 --- a/rust2rpm/conf.py +++ b/rust2rpm/conf.py @@ -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: