From ecf53fecd6e42feeb2fad05f73240dbe6833317b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Hajdan=2C=20Jr?= Date: Fri, 29 Sep 2017 18:28:49 +0200 Subject: [PATCH] gclient flatten: emit conditions for hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: 661382 Change-Id: I0e74273a5e00b4f3cf1d5c22ce0944dc2fa6f31e Reviewed-on: https://chromium-review.googlesource.com/692934 Reviewed-by: Michael Moss Reviewed-by: Aaron Gable Commit-Queue: Paweł Hajdan Jr. --- gclient.py | 8 ++++++++ testing_support/fake_repos.py | 1 + tests/gclient_smoketest.py | 2 ++ 3 files changed, 11 insertions(+) diff --git a/gclient.py b/gclient.py index 1654750984..ea58e96f4f 100755 --- a/gclient.py +++ b/gclient.py @@ -181,6 +181,10 @@ class Hook(object): def name(self): return self._name + @property + def condition(self): + return self._condition + def matches(self, file_list): """Returns true if the pattern matches any of files in the list.""" if not self._pattern: @@ -2042,6 +2046,8 @@ def _HooksToLines(name, hooks): s.append(' "name": "%s",' % hook.name) if hook.pattern is not None: s.append(' "pattern": "%s",' % hook.pattern) + if hook.condition is not None: + s.append(' "condition": "%s",' % hook.condition) s.extend( # Hooks run in the parent directory of their dep. [' "cwd": "%s",' % os.path.normpath(os.path.dirname(dep.name))] + @@ -2069,6 +2075,8 @@ def _HooksOsToLines(hooks_os): s.append(' "name": "%s",' % hook.name) if hook.pattern is not None: s.append(' "pattern": "%s",' % hook.pattern) + if hook.condition is not None: + s.append(' "condition": "%s",' % hook.condition) s.extend( # Hooks run in the parent directory of their dep. [' "cwd": "%s",' % os.path.normpath(os.path.dirname(dep.name))] + diff --git a/testing_support/fake_repos.py b/testing_support/fake_repos.py index 16f6a78c5e..b6c2b87666 100755 --- a/testing_support/fake_repos.py +++ b/testing_support/fake_repos.py @@ -518,6 +518,7 @@ deps_os ={ hooks = [ { 'pattern': '.', + 'condition': 'True', 'action': ['python', '-c', 'open(\\'src/git_hooked1\\', \\'w\\').write(\\'{hook1_contents}\\')'], }, diff --git a/tests/gclient_smoketest.py b/tests/gclient_smoketest.py index 8693934818..e924a386d4 100755 --- a/tests/gclient_smoketest.py +++ b/tests/gclient_smoketest.py @@ -703,6 +703,7 @@ class GClientSmokeGIT(GClientSmokeBase): ' # src', ' {', ' "pattern": ".",', + ' "condition": "True",', ' "cwd": ".",', ' "action": [', ' "python",', @@ -867,6 +868,7 @@ class GClientSmokeGIT(GClientSmokeBase): ' # src', ' {', ' "pattern": ".",', + ' "condition": "True",', ' "cwd": ".",', ' "action": [', ' "python",',