From 86de60ce63a5417fdf7660957668e763087eb27a Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 22 Mar 2026 19:56:56 +0100 Subject: Clean up worktree --- blog/post-receive | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'blog') diff --git a/blog/post-receive b/blog/post-receive index 0721ce3b..f69abaf6 100755 --- a/blog/post-receive +++ b/blog/post-receive @@ -27,7 +27,9 @@ with tempfile.TemporaryDirectory() as tempdir: tempdir = pathlib.Path(tempdir) repo = tempdir / "repo" subprocess.run(["git", "worktree", "add", repo, pushed_commit], check=True) - blog = repo / "blog" - os.chdir(blog) - os.environ["PATH"] = "/home/alex/.local/bin:" + os.environ["PATH"] - subprocess.run(["./build.sh", dest], check=True) + try: + blog = repo / "blog" + os.environ["PATH"] = "/home/alex/.local/bin:" + os.environ["PATH"] + subprocess.run(["./build.sh", dest], check=True, cwd=blog) + finally: + subprocess.run(["git", "worktree", "remove", repo], check=True) -- cgit v1.2.3