From 4285bf4a5482c2dc4aa9278fb88dcca2ebd02e97 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 9 Dec 2025 21:02:01 +0100 Subject: [PATCH 1/2] Fix: release now skips missing pyproject.toml without failing - Updated update_pyproject_version() to gracefully skip missing or unreadable pyproject.toml - Added corresponding unit test ensuring missing file triggers no exception and no file creation - Updated test wording for spec changelog section - Ref: adjustments discussed in ChatGPT conversation (2025-12-09) - https://chatgpt.com/share/69388024-93e4-800f-a09f-bf78a6b9a53f --- pkgmgr/actions/release/files.py | 19 +++++++++++++---- .../unit/pkgmgr/actions/release/test_files.py | 21 ++++++++++++++++--- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/pkgmgr/actions/release/files.py b/pkgmgr/actions/release/files.py index a561b31..8393ba7 100644 --- a/pkgmgr/actions/release/files.py +++ b/pkgmgr/actions/release/files.py @@ -85,7 +85,6 @@ def _open_editor_for_changelog(initial_message: Optional[str] = None) -> str: # File update helpers (pyproject + extra packaging + changelog) # --------------------------------------------------------------------------- - def update_pyproject_version( pyproject_path: str, new_version: str, @@ -99,13 +98,25 @@ def update_pyproject_version( version = "X.Y.Z" and replaces the version part with the given new_version string. + + If the file does not exist, it is skipped without failing the release. """ + if not os.path.exists(pyproject_path): + print( + f"[INFO] pyproject.toml not found at: {pyproject_path}, " + "skipping version update." + ) + return + try: with open(pyproject_path, "r", encoding="utf-8") as f: content = f.read() - except FileNotFoundError: - print(f"[ERROR] pyproject.toml not found at: {pyproject_path}") - sys.exit(1) + except OSError as exc: + print( + f"[WARN] Could not read pyproject.toml at {pyproject_path}: {exc}. " + "Skipping version update." + ) + return pattern = r'^(version\s*=\s*")([^"]+)(")' new_content, count = re.subn( diff --git a/tests/unit/pkgmgr/actions/release/test_files.py b/tests/unit/pkgmgr/actions/release/test_files.py index 9ed57af..1c9496e 100644 --- a/tests/unit/pkgmgr/actions/release/test_files.py +++ b/tests/unit/pkgmgr/actions/release/test_files.py @@ -80,6 +80,21 @@ class TestUpdatePyprojectVersion(unittest.TestCase): self.assertNotEqual(cm.exception.code, 0) + def test_update_pyproject_version_missing_file_is_skipped(self) -> None: + """ + If pyproject.toml does not exist, the function must not raise + and must not create the file. It should simply be skipped. + """ + with tempfile.TemporaryDirectory() as tmpdir: + path = os.path.join(tmpdir, "pyproject.toml") + self.assertFalse(os.path.exists(path)) + + # Must not raise an exception + update_pyproject_version(path, "1.2.3", preview=False) + + # Still no file created + self.assertFalse(os.path.exists(path)) + class TestUpdateFlakeVersion(unittest.TestCase): def test_update_flake_version_normal(self) -> None: @@ -352,11 +367,11 @@ class TestUpdateSpecChangelog(unittest.TestCase): with open(path, "r", encoding="utf-8") as f: content = f.read() - # Neue Stanza muss nach %changelog stehen + # New stanza must appear after the %changelog marker self.assertIn("%changelog", content) self.assertIn("Fedora changelog entry", content) self.assertIn("Test Maintainer ", content) - # Alte Einträge müssen erhalten bleiben + # Old entries must still be present self.assertIn("Old Maintainer ", content) def test_update_spec_changelog_preview_does_not_write(self) -> None: @@ -396,7 +411,7 @@ class TestUpdateSpecChangelog(unittest.TestCase): with open(path, "r", encoding="utf-8") as f: content = f.read() - # Im Preview-Modus darf nichts verändert werden + # In preview mode, the spec file must not change self.assertEqual(content, original) From 6a838ee84fa79e7535e2840bae30febfc9b4f598 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 9 Dec 2025 21:03:24 +0100 Subject: [PATCH 2/2] Release version 0.7.8 --- CHANGELOG.md | 5 +++++ PKGBUILD | 2 +- debian/changelog | 6 ++++++ flake.nix | 2 +- package-manager.spec | 5 ++++- pyproject.toml | 2 +- 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d85c1c9..3594b4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [0.7.8] - 2025-12-09 + +* Missing pyproject.toml doesn't lead to an error during release + + ## [0.7.7] - 2025-12-09 * Added TEST_PATTERN parameter to execute dedicated tests diff --git a/PKGBUILD b/PKGBUILD index 80c5904..8236d7e 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,7 +1,7 @@ # Maintainer: Kevin Veen-Birkenbach pkgname=package-manager -pkgver=0.7.7 +pkgver=0.7.8 pkgrel=1 pkgdesc="Local-flake wrapper for Kevin's package-manager (Nix-based)." arch=('any') diff --git a/debian/changelog b/debian/changelog index 285451e..43a5d33 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +package-manager (0.7.8-1) unstable; urgency=medium + + * Missing pyproject.toml doesn't lead to an error during release + + -- Kevin Veen-Birkenbach Tue, 09 Dec 2025 21:03:24 +0100 + package-manager (0.7.7-1) unstable; urgency=medium * Added TEST_PATTERN parameter to execute dedicated tests diff --git a/flake.nix b/flake.nix index 49aaa78..b28b034 100644 --- a/flake.nix +++ b/flake.nix @@ -31,7 +31,7 @@ rec { pkgmgr = pyPkgs.buildPythonApplication { pname = "package-manager"; - version = "0.7.7"; + version = "0.7.8"; # Use the git repo as source src = ./.; diff --git a/package-manager.spec b/package-manager.spec index 2ca1f65..f36e8b3 100644 --- a/package-manager.spec +++ b/package-manager.spec @@ -1,5 +1,5 @@ Name: package-manager -Version: 0.7.7 +Version: 0.7.8 Release: 1%{?dist} Summary: Wrapper that runs Kevin's package-manager via Nix flake @@ -77,6 +77,9 @@ echo ">>> package-manager removed. Nix itself was not removed." /usr/lib/package-manager/ %changelog +* Tue Dec 09 2025 Kevin Veen-Birkenbach - 0.7.8-1 +- Missing pyproject.toml doesn't lead to an error during release + * Tue Dec 09 2025 Kevin Veen-Birkenbach - 0.7.7-1 - Added TEST_PATTERN parameter to execute dedicated tests diff --git a/pyproject.toml b/pyproject.toml index b9f56f5..63d1511 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" [project] name = "package-manager" -version = "0.7.7" +version = "0.7.8" description = "Kevin's package-manager tool (pkgmgr)" readme = "README.md" requires-python = ">=3.11"