From 59e10115417ac77f47e42c3f13a4f6b58ebe70c2 Mon Sep 17 00:00:00 2001 From: Joanna Wang Date: Mon, 31 Jul 2023 17:14:53 +0000 Subject: [PATCH] Fix hook base paths when repo is not relative but parent is. This makes hooks path behavior match deps path behavior. Bug: 1468658 Change-Id: Ib6685cb52679249b389599ada549e2c4410e812c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4729084 Auto-Submit: Joanna Wang Reviewed-by: Josip Sokcevic Commit-Queue: Joanna Wang --- gclient.py | 5 +++-- tests/gclient_test.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gclient.py b/gclient.py index c096492c1..ddc36acd5 100755 --- a/gclient.py +++ b/gclient.py @@ -897,8 +897,9 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): hooks_cwd = self.root.root_dir if self._use_relative_paths: hooks_cwd = os.path.join(hooks_cwd, self.name) - logging.warning('Updating hook base working directory to %s.', - hooks_cwd) + elif self._relative: + hooks_cwd = os.path.join(hooks_cwd, os.path.dirname(self.name)) + logging.warning('Using hook base working directory: %s.', hooks_cwd) # Only add all hooks if we should sync, otherwise just add custom hooks. # override named sets of hooks by the custom hooks diff --git a/tests/gclient_test.py b/tests/gclient_test.py index 5de4c8d36..06d6fdd58 100755 --- a/tests/gclient_test.py +++ b/tests/gclient_test.py @@ -451,7 +451,7 @@ class GclientTest(trial_dir.TestCase): self.assertEqual( [(h.action, h.effective_cwd) for h in self._get_hooks()], - [(('tata', 'titi'), self.root_dir), + [(('tata', 'titi'), os.path.join(self.root_dir, 'foo')), (('fire', 'lazors'), os.path.join(self.root_dir, 'foo/baz'))]) def testTargetOS(self):