hooks: verify hooks project has worktree before running
Skip hook if its project is not present on disk. Bug: 434232630 Change-Id: I09a8b412d078af7a068d533f7be320d5b02327be Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/494441 Reviewed-by: Scott Lee <ddoman@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
This commit is contained in:
parent
d3eec0acdd
commit
239fad7146
1 changed files with 3 additions and 3 deletions
6
hooks.py
6
hooks.py
|
@ -101,12 +101,11 @@ class RepoHook:
|
|||
self._abort_if_user_denies = abort_if_user_denies
|
||||
|
||||
# Store the full path to the script for convenience.
|
||||
if self._hooks_project:
|
||||
self._script_fullpath = None
|
||||
if self._hooks_project and self._hooks_project.worktree:
|
||||
self._script_fullpath = os.path.join(
|
||||
self._hooks_project.worktree, self._hook_type + ".py"
|
||||
)
|
||||
else:
|
||||
self._script_fullpath = None
|
||||
|
||||
def _GetHash(self):
|
||||
"""Return a hash of the contents of the hooks directory.
|
||||
|
@ -443,6 +442,7 @@ class RepoHook:
|
|||
if (
|
||||
self._bypass_hooks
|
||||
or not self._hooks_project
|
||||
or not self._script_fullpath
|
||||
or self._hook_type not in self._hooks_project.enabled_repo_hooks
|
||||
):
|
||||
return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue