pw_presubmit: Create .git/hooks if it doesn't exist

Change-Id: Iadb59bff6e56c787af1b883ec1c521da41117f4b
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/27080
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/pw_presubmit/py/pw_presubmit/install_hook.py b/pw_presubmit/py/pw_presubmit/install_hook.py
index 1df7011..7a87d1f 100755
--- a/pw_presubmit/py/pw_presubmit/install_hook.py
+++ b/pw_presubmit/py/pw_presubmit/install_hook.py
@@ -41,6 +41,7 @@
     script = os.path.relpath(script, root)
 
     hook_path = root.joinpath('.git', 'hooks', hook)
+    hook_path.parent.mkdir(exist_ok=True)
 
     command = ' '.join(shlex.quote(arg) for arg in (script, *args))