You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.8 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
  2. #
  3. # Use of this source code is governed by a BSD-style license
  4. # that can be found in the LICENSE file in the root of the source
  5. # tree. An additional intellectual property rights grant can be found
  6. # in the file PATENTS. All contributing project authors may
  7. # be found in the AUTHORS file in the root of the source tree.
  8. def _LicenseHeader(input_api):
  9. """Returns the license header regexp."""
  10. # Accept any year number from 2003 to the current year
  11. current_year = int(input_api.time.strftime('%Y'))
  12. allowed_years = (str(s) for s in reversed(xrange(2003, current_year + 1)))
  13. years_re = '(' + '|'.join(allowed_years) + ')'
  14. license_header = (
  15. r'.*? Copyright( \(c\))? %(year)s The WebRTC [Pp]roject [Aa]uthors\. '
  16. r'All [Rr]ights [Rr]eserved\.\n'
  17. r'.*?\n'
  18. r'.*? Use of this source code is governed by a BSD-style license\n'
  19. r'.*? that can be found in the LICENSE file in the root of the source\n'
  20. r'.*? tree\. An additional intellectual property rights grant can be '
  21. r'found\n'
  22. r'.*? in the file PATENTS\. All contributing project authors may\n'
  23. r'.*? be found in the AUTHORS file in the root of the source tree\.\n'
  24. ) % {
  25. 'year': years_re,
  26. }
  27. return license_header
  28. def _CommonChecks(input_api, output_api):
  29. """Checks common to both upload and commit."""
  30. results = []
  31. results.extend(input_api.canned_checks.CheckLicense(
  32. input_api, output_api, _LicenseHeader(input_api)))
  33. return results
  34. def CheckChangeOnUpload(input_api, output_api):
  35. results = []
  36. results.extend(_CommonChecks(input_api, output_api))
  37. return results
  38. def CheckChangeOnCommit(input_api, output_api):
  39. results = []
  40. results.extend(_CommonChecks(input_api, output_api))
  41. return results