From a8d5014a7d1e02589e7bd598ce021083ccc5c7b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 13 Aug 2023 14:12:36 +0200 Subject: [PATCH] use git to cleanup worktree This is faster and less code than using python --- nixpkgs_review/builddir.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/nixpkgs_review/builddir.py b/nixpkgs_review/builddir.py index 4bc9d505..a237803d 100644 --- a/nixpkgs_review/builddir.py +++ b/nixpkgs_review/builddir.py @@ -1,5 +1,4 @@ import os -import shutil import signal from pathlib import Path from tempfile import TemporaryDirectory @@ -58,7 +57,6 @@ def __init__(self, name: str) -> None: self.worktree_dir = self.path.joinpath("nixpkgs") self.worktree_dir.mkdir() - self.worktree_dir = self.worktree_dir os.environ["NIX_PATH"] = self.nixpkgs_path() @@ -73,7 +71,6 @@ def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None: os.environ.update(self.environ) with DisableKeyboardInterrupt(): - shutil.rmtree(self.worktree_dir) - sh(["git", "worktree", "prune"]) + sh(["git", "worktree", "remove", "-f", str(self.worktree_dir)]) self.overlay.cleanup()