From ab38e1d5d4cf610383a7d9bb4083ce4edb67a927 Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 3 Jan 2026 20:35:22 +0000 Subject: [PATCH] Non-native line breaks in `dfetch init` and `dfetch freeze` manifests Fixes #327 --- CHANGELOG.rst | 1 + dfetch/manifest/manifest.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index df37a3cf..c16e6285 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -26,6 +26,7 @@ Release 0.11.0 (unreleased) * Don't consider ignored files for determining local changes (#350) * Avoid waiting for user input in ``git`` & ``svn`` commands (#570) * Extend git ssh command to run in BatchMode (#570) +* Use native line breaks in ``dfetch freeze`` & ``dfetch import`` (#327) Release 0.10.0 (released 2025-03-12) ==================================== diff --git a/dfetch/manifest/manifest.py b/dfetch/manifest/manifest.py index 40e10b4e..dc679d36 100644 --- a/dfetch/manifest/manifest.py +++ b/dfetch/manifest/manifest.py @@ -328,7 +328,11 @@ def dump(self, path: str) -> None: """Dump metadata file to correct path.""" with open(path, "w+", encoding="utf-8") as manifest_file: yaml.dump( - self._as_dict(), manifest_file, Dumper=ManifestDumper, sort_keys=False + self._as_dict(), + manifest_file, + Dumper=ManifestDumper, + sort_keys=False, + line_break=os.linesep, ) def find_name_in_manifest(self, name: str) -> ManifestEntryLocation: @@ -412,12 +416,12 @@ class ManifestDumper(yaml.SafeDumper): # pylint: disable=too-many-ancestors def write_line_break(self, data: Any = None) -> None: """Write a line break.""" - super().write_line_break(data) # type: ignore[unused-ignore] + super().write_line_break(data) # type: ignore[unused-ignore, no-untyped-call] if len(self.indents) == 2 and getattr(self.event, "value", "") != "version": - super().write_line_break() # type: ignore[unused-ignore] + super().write_line_break() # type: ignore[unused-ignore, no-untyped-call] if len(self.indents) == 3 and self._last_additional_break != 2: - super().write_line_break() # type: ignore[unused-ignore] + super().write_line_break() # type: ignore[unused-ignore, no-untyped-call] self._last_additional_break = len(self.indents)