Revert "gclient: remove support for $matching_files in hooks"
This reverts commit 3e6d7c1cbccdc1b7881cf27581488769a6edc22b.
Reason for revert: maybe caused outage.
Original change's description:
> gclient: remove support for $matching_files in hooks
>
> This feature seems to be unused, and removing it will
> simplify handling hooks a little bit.
>
> Bug: 661382
> Change-Id: I89f28dedb7f59cd475b176cfb1f023094520d6b7
> Reviewed-on: https://chromium-review.googlesource.com/509614
> Reviewed-by: Dirk Pranke <dpranke@chromium.org>
> Commit-Queue: Paweł Hajdan Jr. <phajdan.jr@chromium.org>
>
TBR=phajdan.jr@chromium.org,dpranke@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Bug: 661382
Change-Id: I47fe26e7381682b5b428a3775bf27a551c57d5e6
Reviewed-on: https://chromium-review.googlesource.com/512344
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
diff --git a/gclient.py b/gclient.py
index 600c83d..779ce51 100755
--- a/gclient.py
+++ b/gclient.py
@@ -724,7 +724,7 @@
hooks_to_run.append(hook)
if self.recursion_limit:
- self._pre_deps_hooks = [self.GetHookAction(hook) for hook in
+ self._pre_deps_hooks = [self.GetHookAction(hook, []) for hook in
local_scope.get('pre_deps_hooks', [])]
self.add_dependencies_and_close(deps_to_add, hooks_to_run)
@@ -879,15 +879,19 @@
self._processed = True
@staticmethod
- def GetHookAction(hook_dict):
+ def GetHookAction(hook_dict, matching_file_list):
"""Turns a parsed 'hook' dict into an executable command."""
logging.debug(hook_dict)
+ logging.debug(matching_file_list)
command = hook_dict['action'][:]
if command[0] == 'python':
# If the hook specified "python" as the first item, the action is a
# Python script. Run it by starting a new copy of the same
# interpreter.
command[0] = sys.executable
+ if '$matching_files' in command:
+ splice_index = command.index('$matching_files')
+ command[splice_index:splice_index + 1] = matching_file_list
return command
def GetHooks(self, options):
@@ -909,7 +913,7 @@
gclient_scm.GetScmName(self.parsed_url) in ('git', None) or
os.path.isdir(os.path.join(self.root.root_dir, self.name, '.git'))):
for hook_dict in self.deps_hooks:
- result.append(self.GetHookAction(hook_dict))
+ result.append(self.GetHookAction(hook_dict, []))
else:
# Run hooks on the basis of whether the files from the gclient operation
# match each hook's pattern.
@@ -919,7 +923,7 @@
f for f in self.file_list_and_children if pattern.search(f)
]
if matching_file_list:
- result.append(self.GetHookAction(hook_dict))
+ result.append(self.GetHookAction(hook_dict, matching_file_list))
for s in self.dependencies:
result.extend(s.GetHooks(options))
return result