mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
gclient: add use_relative_hooks
When a recursive dependency has use_relative_paths it also makes sense to have the hooks working directory by the dependency's directory. Otherwise if a hook uses one of the relative dependencies it is impossible to know which path prefix to use. However we cannot change the behavior of hooks with use_relative_paths because it would break existing projects that use_relative_paths but hardcoded the prefix for hooks. Instead we add a second boolean, use_relative_hooks that triggers the behavior. Adds tests for the new behavior and a test for existing interactio between hooks and recursedeps. BUG=chromium:875245 Change-Id: Ie4c526baa425ff887b3be54e0feca7c597ededec Reviewed-on: https://chromium-review.googlesource.com/1213327 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
This commit is contained in:
committed by
Commit Bot
parent
25c380cf9d
commit
a68660d0bb
@@ -320,7 +320,7 @@ class FakeReposBase(object):
|
||||
|
||||
class FakeRepos(FakeReposBase):
|
||||
"""Implements populateGit()."""
|
||||
NB_GIT_REPOS = 14
|
||||
NB_GIT_REPOS = 16
|
||||
|
||||
def populateGit(self):
|
||||
# Testing:
|
||||
@@ -550,6 +550,8 @@ deps = {
|
||||
'url': None,
|
||||
},
|
||||
'src/repo8': '/repo_8',
|
||||
'src/repo15': '/repo_15',
|
||||
'src/repo16': '/repo_16',
|
||||
}
|
||||
deps_os ={
|
||||
'mac': {
|
||||
@@ -592,6 +594,8 @@ hooks_os = {
|
||||
recursedeps = [
|
||||
'src/repo2',
|
||||
'src/repo8',
|
||||
'src/repo15',
|
||||
'src/repo16',
|
||||
]""" % {
|
||||
'git_base': self.git_base,
|
||||
'hash': self.git_hashes['repo_2'][1][0][:7]
|
||||
@@ -778,6 +782,29 @@ deps = {
|
||||
'origin': 'git/repo_14@2\n'
|
||||
})
|
||||
|
||||
# A repo with a hook to be recursed in, without use_relative_hooks
|
||||
self._commit_git('repo_15', {
|
||||
'DEPS': textwrap.dedent("""\
|
||||
hooks = [{
|
||||
"name": "absolute_cwd",
|
||||
"pattern": ".",
|
||||
"action": ["python", "-c", "pass"]
|
||||
}]"""),
|
||||
'origin': 'git/repo_15@2\n'
|
||||
})
|
||||
# A repo with a hook to be recursed in, with use_relative_hooks
|
||||
self._commit_git('repo_16', {
|
||||
'DEPS': textwrap.dedent("""\
|
||||
use_relative_paths=True
|
||||
use_relative_hooks=True
|
||||
hooks = [{
|
||||
"name": "relative_cwd",
|
||||
"pattern": ".",
|
||||
"action": ["python", "relative.py"]
|
||||
}]"""),
|
||||
'relative.py': 'pass',
|
||||
'origin': 'git/repo_16@2\n'
|
||||
})
|
||||
|
||||
class FakeRepoSkiaDEPS(FakeReposBase):
|
||||
"""Simulates the Skia DEPS transition in Chrome."""
|
||||
|
||||
Reference in New Issue
Block a user