From ae9b54ebbf243a91bf48ee0f15754f37ead0fbb0 Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Sat, 27 Jan 2024 23:41:02 +0000 Subject: [PATCH] Optimize `validate_sha()` with `--max-count=1` Optimize the `validate_sha()` function with `--max-count=1` to prevent printing the git log of every single commit. This makes the function near instant. --- cherry_picker/cherry_picker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cherry_picker/cherry_picker.py b/cherry_picker/cherry_picker.py index 3e59f39..5ff8615 100755 --- a/cherry_picker/cherry_picker.py +++ b/cherry_picker/cherry_picker.py @@ -861,7 +861,7 @@ def validate_sha(sha): raises ValueError if the sha does not reference a commit within the repo """ - cmd = ["git", "log", "-r", sha] + cmd = ["git", "log", "--max-count=1", "-r", sha] try: subprocess.check_output(cmd, stderr=subprocess.STDOUT) except subprocess.SubprocessError: