pw_presubmit: Remove deprecated install_hook function
Fixes: b/243715416
Change-Id: I7e4f1fc582c361898e75335295c3be1ec66d77db
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/109232
Reviewed-by: Rob Mohr <mohrr@google.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@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 7aad89e..fc86fcf 100755
--- a/pw_presubmit/py/pw_presubmit/install_hook.py
+++ b/pw_presubmit/py/pw_presubmit/install_hook.py
@@ -54,22 +54,6 @@
return shlex.quote(arg)
-def install_hook(script,
- hook: str,
- args: Sequence[str] = (),
- repository: Union[Path, str] = '.') -> None:
- """This function is deprecated; use install_git_hook instead.
-
- This version of the function takes the script separately from the arguments
- and calculates the relative path to the script from the root of the repo.
- This does not work well when the path is to a file installed in the virtual
- environment, since the execute permission may be lost. Instead of using a
- path to a script, invoke the script from `python -m` or the `pw` command.
- """
- root = git_repo_root(repository).resolve()
- install_git_hook(hook, [os.path.relpath(script, root), *args], repository)
-
-
def install_git_hook(hook: str,
command: Sequence[Union[Path, str]],
repository: Union[Path, str] = '.') -> None:
@@ -129,7 +113,8 @@
hook_path)
-def argument_parser(parser=None) -> argparse.ArgumentParser:
+def argument_parser(
+ parser: argparse.ArgumentParser = None) -> argparse.ArgumentParser:
if parser is None:
parser = argparse.ArgumentParser(description=__doc__)
@@ -148,18 +133,13 @@
parser.add_argument('--hook',
required=True,
help='Which type of Git hook to create')
- parser.add_argument('-s',
- '--script',
- required=True,
- type=path,
- help='Path to the script to execute in the hook')
- parser.add_argument('args',
+ parser.add_argument('command',
nargs='*',
- help='Arguments to provide to the commit hook')
+ help='Command to run in the commit hook')
return parser
if __name__ == '__main__':
logging.basicConfig(format='%(message)s', level=logging.INFO)
- install_hook(**vars(argument_parser().parse_args()))
+ install_git_hook(**vars(argument_parser().parse_args()))