From a1b09b482576743793f3cfe3baaca55b121793fd Mon Sep 17 00:00:00 2001 From: wadabum <23560633+wadabum@users.noreply.github.com> Date: Mon, 18 Aug 2025 17:38:52 +0200 Subject: [PATCH 1/3] test_git_fetch_file - support any python --- test_git_fetch_file.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test_git_fetch_file.py b/test_git_fetch_file.py index fe1b9ca..092f2da 100644 --- a/test_git_fetch_file.py +++ b/test_git_fetch_file.py @@ -1,3 +1,4 @@ +import re import unittest import subprocess import tempfile @@ -14,8 +15,8 @@ def test_argparse_argumentparser(self): script_path = subprocess.check_output( ["git", "config", "alias.fetch-file"], text=True ).strip() - if script_path.startswith("!python3 "): - script_path = script_path[len("!python3 "):] + # remove any leading "!something " prefix + script_path = re.sub(r"^!\S+\s+", "", script_path) with open(script_path, "r") as f: source = f.read() self.assertIn("argparse.ArgumentParser", source, "failed to find argparse.ArgumentParser") From 27e1c0d2949a5af9c2c2e74142896b46274c0205 Mon Sep 17 00:00:00 2001 From: wadabum <23560633+wadabum@users.noreply.github.com> Date: Mon, 18 Aug 2025 17:42:28 +0200 Subject: [PATCH 2/3] test_git_fetch_file - support "git-bash.exe" while on windows, user may configure his git-alias as "!python /c/some/path.py" --- test_git_fetch_file.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test_git_fetch_file.py b/test_git_fetch_file.py index 092f2da..c5f74c9 100644 --- a/test_git_fetch_file.py +++ b/test_git_fetch_file.py @@ -17,6 +17,9 @@ def test_argparse_argumentparser(self): ).strip() # remove any leading "!something " prefix script_path = re.sub(r"^!\S+\s+", "", script_path) + # when this is actually git-bash.exe, the path may need to be translated + if os.name == 'nt' and script_path.startswith('/'): + script_path = script_path[1] + ':' + script_path[2:] with open(script_path, "r") as f: source = f.read() self.assertIn("argparse.ArgumentParser", source, "failed to find argparse.ArgumentParser") From 7731d8e1189c5dd10e5722bb207cb2d57b379119 Mon Sep 17 00:00:00 2001 From: wadabum <23560633+wadabum@users.noreply.github.com> Date: Mon, 18 Aug 2025 17:44:05 +0200 Subject: [PATCH 3/3] test_git_fetch_file - fix cleanup windows wont let you delete the folder you are in (the tmp) --- test_git_fetch_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_git_fetch_file.py b/test_git_fetch_file.py index c5f74c9..a67be89 100644 --- a/test_git_fetch_file.py +++ b/test_git_fetch_file.py @@ -35,8 +35,8 @@ def setUp(self): subprocess.run(["git", "config", "user.email", "test@example.com"], check=True) def tearDown(self): - shutil.rmtree(self.tmpdir) os.chdir(self.oldpwd) + shutil.rmtree(self.tmpdir) class TestAdd(TestGitRepository):