-
Notifications
You must be signed in to change notification settings - Fork 3
/
revhook
51 lines (38 loc) · 1.45 KB
/
revhook
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- mode: python -*-
# No Copyright (-) 2010 The Ampify Authors. This file is under the
# Public Domain license that can be found in the root LICENSE file.
def JSLint(input_api, output_api):
files = [
f.AbsoluteLocalPath() for f in input_api.AffectedSourceFiles(
lambda x: x.AbsoluteLocalPath().endswith('.js')
)
]
results = []; out = results.append
for filename in files:
process = input_api.subprocess.Popen(
['nodelint.js', filename],
stdin=input_api.subprocess.PIPE,
stdout=input_api.subprocess.PIPE,
stderr=input_api.subprocess.PIPE
)
stdout, stderr = process.communicate()
if process.returncode:
out(output_api.PresubmitPromptWarning(
"JSLinting '%s' failed:" % filename,
long_text="%s" % stdout
))
return results
def CheckChange(input_api, output_api, commit):
results = []
results += input_api.canned_checks.CheckChangeHasNoStrayWhitespace(
input_api, output_api
)
results += input_api.canned_checks.CheckChangeHasDescription(
input_api, output_api
)
results.extend(JSLint(input_api, output_api))
return results
def CheckChangeOnUpload(input_api, output_api):
return CheckChange(input_api, output_api, False)
def CheckChangeOnCommit(input_api, output_api):
return CheckChange(input_api, output_api, True)