Add upload and commit checks to a common function.
Add HasDescription and HasNoStrayWhitespace checks. BUG=none TEST=uploaded a dummy CL with violations. Review URL: https://webrtc-codereview.appspot.com/372004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1556 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
a8c568f0a4
commit
53df136240
26
PRESUBMIT.py
26
PRESUBMIT.py
@ -6,8 +6,9 @@
|
|||||||
# in the file PATENTS. All contributing project authors may
|
# in the file PATENTS. All contributing project authors may
|
||||||
# be found in the AUTHORS file in the root of the source tree.
|
# be found in the AUTHORS file in the root of the source tree.
|
||||||
|
|
||||||
def CheckChangeOnUpload(input_api, output_api):
|
def _LicenseHeader(input_api):
|
||||||
webrtc_license_header = (
|
"""Returns the license header regexp."""
|
||||||
|
license_header = (
|
||||||
r'.*? Copyright \(c\) %(year)s The WebRTC project authors\. '
|
r'.*? Copyright \(c\) %(year)s The WebRTC project authors\. '
|
||||||
r'All Rights Reserved\.\n'
|
r'All Rights Reserved\.\n'
|
||||||
r'.*?\n'
|
r'.*?\n'
|
||||||
@ -20,19 +21,34 @@ def CheckChangeOnUpload(input_api, output_api):
|
|||||||
) % {
|
) % {
|
||||||
'year': input_api.time.strftime('%Y'),
|
'year': input_api.time.strftime('%Y'),
|
||||||
}
|
}
|
||||||
|
return license_header
|
||||||
|
|
||||||
|
def _CommonChecks(input_api, output_api):
|
||||||
|
"""Checks common to both upload and commit."""
|
||||||
results = []
|
results = []
|
||||||
# Ideally, maxlen would be 80.
|
|
||||||
results.extend(input_api.canned_checks.CheckLongLines(
|
results.extend(input_api.canned_checks.CheckLongLines(
|
||||||
input_api, output_api, maxlen=95))
|
input_api, output_api))
|
||||||
results.extend(input_api.canned_checks.CheckChangeHasNoTabs(
|
results.extend(input_api.canned_checks.CheckChangeHasNoTabs(
|
||||||
input_api, output_api))
|
input_api, output_api))
|
||||||
|
results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace(
|
||||||
|
input_api, output_api))
|
||||||
|
results.extend(input_api.canned_checks.CheckChangeTodoHasOwner(
|
||||||
|
input_api, output_api))
|
||||||
results.extend(input_api.canned_checks.CheckLicense(
|
results.extend(input_api.canned_checks.CheckLicense(
|
||||||
input_api, output_api, webrtc_license_header))
|
input_api, output_api, _LicenseHeader(input_api)))
|
||||||
|
return results
|
||||||
|
|
||||||
|
def CheckChangeOnUpload(input_api, output_api):
|
||||||
|
results = []
|
||||||
|
results.extend(_CommonChecks(input_api, output_api))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def CheckChangeOnCommit(input_api, output_api):
|
def CheckChangeOnCommit(input_api, output_api):
|
||||||
results = []
|
results = []
|
||||||
|
results.extend(_CommonChecks(input_api, output_api))
|
||||||
results.extend(input_api.canned_checks.CheckOwners(input_api, output_api))
|
results.extend(input_api.canned_checks.CheckOwners(input_api, output_api))
|
||||||
|
results.extend(input_api.canned_checks.CheckChangeWasUploaded(
|
||||||
|
input_api, output_api))
|
||||||
|
results.extend(input_api.canned_checks.CheckChangeHasDescription(
|
||||||
|
input_api, output_api))
|
||||||
return results
|
return results
|
||||||
|
Loading…
Reference in New Issue
Block a user