diff options
| author | Gavin Mak <gavinmak@google.com> | 2025-07-25 23:20:06 +0000 |
|---|---|---|
| committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2025-07-28 08:37:08 -0700 |
| commit | 239fad7146e04c631825c340f23d6e69947aac50 (patch) | |
| tree | bcad23e48c1ecf1f18373cc5a3e377b76198f632 | |
| parent | d3eec0acdd856e54747494465a33ebf72f321cb1 (diff) | |
| download | git-repo-239fad7146e04c631825c340f23d6e69947aac50.tar.gz | |
hooks: verify hooks project has worktree before runningv2.57.2
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>
| -rw-r--r-- | hooks.py | 6 |
1 files changed, 3 insertions, 3 deletions
| @@ -101,12 +101,11 @@ class RepoHook: | |||
| 101 | self._abort_if_user_denies = abort_if_user_denies | 101 | self._abort_if_user_denies = abort_if_user_denies |
| 102 | 102 | ||
| 103 | # Store the full path to the script for convenience. | 103 | # Store the full path to the script for convenience. |
| 104 | if self._hooks_project: | 104 | self._script_fullpath = None |
| 105 | if self._hooks_project and self._hooks_project.worktree: | ||
| 105 | self._script_fullpath = os.path.join( | 106 | self._script_fullpath = os.path.join( |
| 106 | self._hooks_project.worktree, self._hook_type + ".py" | 107 | self._hooks_project.worktree, self._hook_type + ".py" |
| 107 | ) | 108 | ) |
| 108 | else: | ||
| 109 | self._script_fullpath = None | ||
| 110 | 109 | ||
| 111 | def _GetHash(self): | 110 | def _GetHash(self): |
| 112 | """Return a hash of the contents of the hooks directory. | 111 | """Return a hash of the contents of the hooks directory. |
| @@ -443,6 +442,7 @@ class RepoHook: | |||
| 443 | if ( | 442 | if ( |
| 444 | self._bypass_hooks | 443 | self._bypass_hooks |
| 445 | or not self._hooks_project | 444 | or not self._hooks_project |
| 445 | or not self._script_fullpath | ||
| 446 | or self._hook_type not in self._hooks_project.enabled_repo_hooks | 446 | or self._hook_type not in self._hooks_project.enabled_repo_hooks |
| 447 | ): | 447 | ): |
| 448 | return True | 448 | return True |
