From 004923399e12dfff8c4853a1331f39dc91f3e248 Mon Sep 17 00:00:00 2001 From: Andrii Shyshkalov Date: Tue, 23 May 2017 08:50:22 +0000 Subject: [PATCH] Revert "gclient: remove support for $matching_files in hooks" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 > Commit-Queue: Paweł Hajdan Jr. > 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 Commit-Queue: Andrii Shyshkalov --- gclient.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gclient.py b/gclient.py index 600c83ddb..779ce51ac 100755 --- a/gclient.py +++ b/gclient.py @@ -724,7 +724,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): 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 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): 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 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): 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 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): 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