Commit 00492339 authored by Andrii Shyshkalov's avatar Andrii Shyshkalov Committed by Commit Bot

Revert "gclient: remove support for $matching_files in hooks"

This reverts commit 3e6d7c1c.

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/512344Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
parent b4f9d904
...@@ -724,7 +724,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): ...@@ -724,7 +724,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
hooks_to_run.append(hook) hooks_to_run.append(hook)
if self.recursion_limit: 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', [])] local_scope.get('pre_deps_hooks', [])]
self.add_dependencies_and_close(deps_to_add, hooks_to_run) self.add_dependencies_and_close(deps_to_add, hooks_to_run)
...@@ -879,15 +879,19 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): ...@@ -879,15 +879,19 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
self._processed = True self._processed = True
@staticmethod @staticmethod
def GetHookAction(hook_dict): def GetHookAction(hook_dict, matching_file_list):
"""Turns a parsed 'hook' dict into an executable command.""" """Turns a parsed 'hook' dict into an executable command."""
logging.debug(hook_dict) logging.debug(hook_dict)
logging.debug(matching_file_list)
command = hook_dict['action'][:] command = hook_dict['action'][:]
if command[0] == 'python': if command[0] == 'python':
# If the hook specified "python" as the first item, the action is a # 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 # Python script. Run it by starting a new copy of the same
# interpreter. # interpreter.
command[0] = sys.executable 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 return command
def GetHooks(self, options): def GetHooks(self, options):
...@@ -909,7 +913,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): ...@@ -909,7 +913,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
gclient_scm.GetScmName(self.parsed_url) in ('git', None) or gclient_scm.GetScmName(self.parsed_url) in ('git', None) or
os.path.isdir(os.path.join(self.root.root_dir, self.name, '.git'))): os.path.isdir(os.path.join(self.root.root_dir, self.name, '.git'))):
for hook_dict in self.deps_hooks: for hook_dict in self.deps_hooks:
result.append(self.GetHookAction(hook_dict)) result.append(self.GetHookAction(hook_dict, []))
else: else:
# Run hooks on the basis of whether the files from the gclient operation # Run hooks on the basis of whether the files from the gclient operation
# match each hook's pattern. # match each hook's pattern.
...@@ -919,7 +923,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): ...@@ -919,7 +923,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
f for f in self.file_list_and_children if pattern.search(f) f for f in self.file_list_and_children if pattern.search(f)
] ]
if matching_file_list: if matching_file_list:
result.append(self.GetHookAction(hook_dict)) result.append(self.GetHookAction(hook_dict, matching_file_list))
for s in self.dependencies: for s in self.dependencies:
result.extend(s.GetHooks(options)) result.extend(s.GetHooks(options))
return result return result
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment