diff --git a/gclient.py b/gclient.py index 165475098..ea58e96f4 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 16f6a78c5..b6c2b8766 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 869393481..e924a386d 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",',