diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2021-10-04 16:14:46 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2021-10-04 16:14:46 -0400 |
commit | 40f671f008afae4d45a023ad5054a5755c51dc68 (patch) | |
tree | c58ab139bf5027adb8a12327e87f26805b824b49 | |
parent | d2128a8865db4544370599221edf231fab971999 (diff) | |
download | patatt-40f671f008afae4d45a023ad5054a5755c51dc68.tar.gz |
install-hook: make sure the hooks path exists
Before writing the hook, make sure the .git/hooks path exists.
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://github.com/mricon/patatt/pull/1
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r-- | patatt/__init__.py | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/patatt/__init__.py b/patatt/__init__.py index 6789151..c6b1ac5 100644 --- a/patatt/__init__.py +++ b/patatt/__init__.py @@ -1122,6 +1122,7 @@ def cmd_install_hook(cmdargs, config: dict): # noqa if os.path.exists(hookfile): logger.critical('Hook already exists: %s', hookfile) sys.exit(1) + Path(os.path.join(gitrepo, '.git', 'hooks')).mkdir(parents=True, exist_ok=True) with open(hookfile, 'w') as fh: fh.write('#!/bin/sh\n') fh.write('# installed by patatt install-hook\n') |