From 28ff2f7a8e34502ad3d617499fbedce7893a20e5 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sat, 28 Nov 2026 14:28:34 +0000 Subject: [PATCH] refactor(release): tighten the release-at-cwd code to Codacy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The docstrings of _at_cwd_checkout, release_at_cwd and has_explicit_selection end with a blank line after their last section (pydocstyle D413). TestReleaseCwdCheckout calls git through shutil.which and skips without git (Bandit B607). Kept on purpose, each contradicts another rule: D205/D212/D415 want a summary sentence (AGENTS allows docstrings only as parameter docs), D406/D407 numpy sections (AGENTS: Args: docstrings), B404/B603 on test subprocess calls (silencing needs # nosec, which quality clean.tool-pragma forbids). | 🌿 Branch | 📊 Diff stat | 🎯 Fix | 💥 Break | 💸 Tokens | ⏱️ Velocity | 🛡️ Security | 🏆 Score | Gate | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | fix/release-cwd | 3 files +8/-1 | 90 % | 2 % | – | – | 100 % | 88 | ✅ 90/5, tokens and velocity <= 100, security 100 % | Refs: https://github.com/kevinveenbirkenbach/package-manager/pull/12 Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- src/pkgmgr/cli/commands/release.py | 2 ++ src/pkgmgr/core/repository/selected.py | 1 + tests/integration/test_release_publish_hook.py | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pkgmgr/cli/commands/release.py b/src/pkgmgr/cli/commands/release.py index 6b1d3c4..8f107c2 100644 --- a/src/pkgmgr/cli/commands/release.py +++ b/src/pkgmgr/cli/commands/release.py @@ -25,6 +25,7 @@ def _at_cwd_checkout(args, selected: list[Repository]) -> list[Repository]: selected unchanged after an explicit selection or outside git; else each repository pointed at the current directory's git toplevel, so a release from a nested clone never commits in the configured main checkout. + """ if has_explicit_selection(args): return selected @@ -42,6 +43,7 @@ def release_at_cwd(args, ctx: CLIContext, selected: list[Repository]) -> None: ctx: the CLI context. selected: the repositories dispatch picked; without an explicit selection each is released in the current directory's checkout. + """ handle_release(args, ctx, _at_cwd_checkout(args, selected)) diff --git a/src/pkgmgr/core/repository/selected.py b/src/pkgmgr/core/repository/selected.py index 20e5cbb..f76422c 100644 --- a/src/pkgmgr/core/repository/selected.py +++ b/src/pkgmgr/core/repository/selected.py @@ -144,6 +144,7 @@ def has_explicit_selection(args) -> bool: Returns: True when --all, an identifier, --category, --tag or --string picks the repositories instead of the current directory. + """ return bool( getattr(args, "all", False) diff --git a/tests/integration/test_release_publish_hook.py b/tests/integration/test_release_publish_hook.py index 9073e06..562001c 100644 --- a/tests/integration/test_release_publish_hook.py +++ b/tests/integration/test_release_publish_hook.py @@ -2,6 +2,7 @@ from __future__ import annotations import io import os +import shutil import subprocess import tempfile import unittest @@ -13,6 +14,8 @@ from unittest.mock import patch from pkgmgr.actions.release.git_ops import ensure_clean_and_synced from pkgmgr.cli.context import CLIContext +GIT = shutil.which("git") + class TestIntegrationReleasePublishHook(unittest.TestCase): def _ctx(self) -> SimpleNamespace: @@ -73,9 +76,10 @@ class TestIntegrationReleasePublishHook(unittest.TestCase): m_publish.assert_not_called() +@unittest.skipUnless(GIT, "git builds the clones under test") class TestReleaseCwdCheckout(unittest.TestCase): def _sh(self, cwd: str, *argv: str) -> None: - subprocess.run(["git", *argv], cwd=cwd, check=True, capture_output=True) + subprocess.run([GIT, *argv], cwd=cwd, check=True, capture_output=True) def setUp(self) -> None: self._tmp = tempfile.TemporaryDirectory()