From 239fad7146e04c631825c340f23d6e69947aac50 Mon Sep 17 00:00:00 2001 From: Gavin Mak Date: Fri, 25 Jul 2025 23:20:06 +0000 Subject: 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 Tested-by: Gavin Mak Commit-Queue: Gavin Mak --- hooks.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'hooks.py') diff --git a/hooks.py b/hooks.py index fc31a5ef..d6e1e3bb 100644 --- a/hooks.py +++ b/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 -- cgit v1.2.3-54-g00ecf