From 8a3643638ae3218fad91144ee53b94445fc0b164 Mon Sep 17 00:00:00 2001 From: Derek Wan Date: Wed, 31 Dec 2025 20:36:31 +0900 Subject: [PATCH 1/5] 2025-12-31 20:36:31 (Wed) > DW-Mac > derekwan From 49f7ea3e3278b63416beff525afb26ce2850c720 Mon Sep 17 00:00:00 2001 From: Derek Wan Date: Wed, 31 Dec 2025 20:36:39 +0900 Subject: [PATCH 2/5] 2025-12-31 20:36:39 (Wed) > DW-Mac > derekwan --- pyproject.toml | 4 ++-- src/tests/test_subprocess.py | 2 -- src/utilities/__init__.py | 2 +- src/utilities/subprocess.py | 8 ++++++++ uv.lock | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 52a3a57fff..146684e160 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -101,7 +101,7 @@ name = "dycw-utilities" readme = "README.md" requires-python = ">= 3.12" - version = "0.174.19" + version = "0.174.20" [project.entry-points.pytest11] pytest-randomly = "utilities.pytest_plugins.pytest_randomly" @@ -135,7 +135,7 @@ # bump-my-version [tool.bumpversion] allow_dirty = true - current_version = "0.174.19" + current_version = "0.174.20" [[tool.bumpversion.files]] filename = "src/utilities/__init__.py" diff --git a/src/tests/test_subprocess.py b/src/tests/test_subprocess.py index 96af63649c..93f556ee0f 100644 --- a/src/tests/test_subprocess.py +++ b/src/tests/test_subprocess.py @@ -240,7 +240,6 @@ def test_subs(self) -> None: class TestGitBranchCurrent: @throttle(delta=5 * MINUTE) - @mark.only def test_main(self, *, git_repo_url: str, tmp_path: Path) -> None: git_clone(git_repo_url, tmp_path) result = git_branch_current(tmp_path) @@ -249,7 +248,6 @@ def test_main(self, *, git_repo_url: str, tmp_path: Path) -> None: class TestGitCheckout: @throttle(delta=5 * MINUTE) - @mark.only def test_main(self, *, git_repo_url: str, tmp_path: Path) -> None: git_clone(git_repo_url, tmp_path) git_checkout("branch", tmp_path) diff --git a/src/utilities/__init__.py b/src/utilities/__init__.py index a60fe75346..b992bfe185 100644 --- a/src/utilities/__init__.py +++ b/src/utilities/__init__.py @@ -1,3 +1,3 @@ from __future__ import annotations -__version__ = "0.174.19" +__version__ = "0.174.20" diff --git a/src/utilities/subprocess.py b/src/utilities/subprocess.py index 744f55cb0a..aeaaab5489 100644 --- a/src/utilities/subprocess.py +++ b/src/utilities/subprocess.py @@ -49,6 +49,13 @@ ## +def apt_install(package: str, /, *, update: bool = False, sudo: bool = False) -> None: + """Install a package.""" + if update: # pragma: no cover + run(*maybe_sudo_cmd(*APT_UPDATE, sudo=sudo)) + run(*maybe_sudo_cmd(*apt_install_cmd(package), sudo=sudo)) + + def apt_install_cmd(package: str, /) -> list[str]: """Command to use 'apt' to install a package.""" return ["apt", "install", "-y", package] @@ -1207,6 +1214,7 @@ def yield_ssh_temp_dir( "RsyncCmdError", "RsyncCmdNoSourcesError", "RsyncCmdSourcesNotFoundError", + "apt_install", "apt_install_cmd", "cd_cmd", "chmod", diff --git a/uv.lock b/uv.lock index e4ad426b98..52979f784e 100644 --- a/uv.lock +++ b/uv.lock @@ -634,7 +634,7 @@ wheels = [ [[package]] name = "dycw-utilities" -version = "0.174.19" +version = "0.174.20" source = { editable = "." } dependencies = [ { name = "atomicwrites" }, From cefe829fc17a349a5734f7486b92736eda237c68 Mon Sep 17 00:00:00 2001 From: Derek Wan Date: Wed, 31 Dec 2025 21:05:32 +0900 Subject: [PATCH 3/5] 2025-12-31 21:05:32 (Wed) > DW-Mac > derekwan --- src/utilities/subprocess.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/utilities/subprocess.py b/src/utilities/subprocess.py index aeaaab5489..fc7618f058 100644 --- a/src/utilities/subprocess.py +++ b/src/utilities/subprocess.py @@ -257,7 +257,7 @@ def git_clone( rm(path, sudo=sudo) run(*maybe_sudo_cmd(*git_clone_cmd(url, path), sudo=sudo)) if branch is not None: - run(*maybe_sudo_cmd(*git_hard_reset_cmd(branch=branch), sudo=sudo), cwd=path) + git_checkout(branch, path) def git_clone_cmd(url: str, path: PathLike, /) -> list[str]: @@ -268,15 +268,6 @@ def git_clone_cmd(url: str, path: PathLike, /) -> list[str]: ## -def git_hard_reset_cmd(*, branch: str | None = None) -> list[str]: - """Command to use 'git hard-reset' to hard reset a repository.""" - branch_use = "master" if branch is None else branch - return ["git", "hard-reset", branch_use] - - -## - - def maybe_parent(path: PathLike, /, *, parent: bool = False) -> Path: """Get the parent of a path, if required.""" path = Path(path) @@ -1230,7 +1221,6 @@ def yield_ssh_temp_dir( "git_checkout_cmd", "git_clone", "git_clone_cmd", - "git_hard_reset_cmd", "maybe_parent", "maybe_sudo_cmd", "mkdir", From ccafe511f946437546b7a149bcde3c8b0805c8bb Mon Sep 17 00:00:00 2001 From: Derek Wan Date: Wed, 31 Dec 2025 21:05:38 +0900 Subject: [PATCH 4/5] 2025-12-31 21:05:38 (Wed) > DW-Mac > derekwan --- src/tests/test_subprocess.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tests/test_subprocess.py b/src/tests/test_subprocess.py index 93f556ee0f..a7d68231a2 100644 --- a/src/tests/test_subprocess.py +++ b/src/tests/test_subprocess.py @@ -38,7 +38,6 @@ git_checkout_cmd, git_clone, git_clone_cmd, - git_hard_reset_cmd, maybe_parent, maybe_sudo_cmd, mkdir, From e1598b3eb03feaeb48d02be554b27713a8515468 Mon Sep 17 00:00:00 2001 From: Derek Wan Date: Wed, 31 Dec 2025 21:05:42 +0900 Subject: [PATCH 5/5] 2025-12-31 21:05:42 (Wed) > DW-Mac > derekwan --- src/tests/test_subprocess.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/tests/test_subprocess.py b/src/tests/test_subprocess.py index a7d68231a2..272960417a 100644 --- a/src/tests/test_subprocess.py +++ b/src/tests/test_subprocess.py @@ -281,18 +281,6 @@ def test_main(self, *, git_repo_url: str) -> None: assert result == expected -class TestGitHardResetCmd: - def test_main(self) -> None: - result = git_hard_reset_cmd() - expected = ["git", "hard-reset", "master"] - assert result == expected - - def test_branch(self) -> None: - result = git_hard_reset_cmd(branch="dev") - expected = ["git", "hard-reset", "dev"] - assert result == expected - - class TestMaybeParent: def test_main(self) -> None: result = maybe_parent("~/path")