gclient flatten: emit conditions for hooks

Bug: 661382
Change-Id: I0e74273a5e00b4f3cf1d5c22ce0944dc2fa6f31e
Reviewed-on: https://chromium-review.googlesource.com/692934
Reviewed-by: Michael Moss <mmoss@chromium.org>
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Paweł Hajdan Jr. <phajdan.jr@chromium.org>
changes/34/692934/2
Paweł Hajdan, Jr 8 years ago committed by Commit Bot
parent 355b70412f
commit ecf53fecd6

@ -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))] +

@ -518,6 +518,7 @@ deps_os ={
hooks = [
{
'pattern': '.',
'condition': 'True',
'action': ['python', '-c',
'open(\\'src/git_hooked1\\', \\'w\\').write(\\'{hook1_contents}\\')'],
},

@ -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",',

Loading…
Cancel
Save