test_mbox_shortlog.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Checks related to the patch's summary
  2. #
  3. # Copyright (C) 2016 Intel Corporation
  4. #
  5. # SPDX-License-Identifier: GPL-2.0-only
  6. import base
  7. import parse_shortlog
  8. import pyparsing
  9. maxlength = 90
  10. class Shortlog(base.Base):
  11. def test_shortlog_format(self):
  12. for commit in Shortlog.commits:
  13. shortlog = commit.shortlog
  14. if not shortlog.strip():
  15. self.skip('Empty shortlog, no reason to execute shortlog format test')
  16. else:
  17. # no reason to re-check on revert shortlogs
  18. if shortlog.startswith('Revert "'):
  19. continue
  20. try:
  21. parse_shortlog.shortlog.parseString(shortlog)
  22. except pyparsing.ParseException as pe:
  23. self.fail('Commit shortlog (first line of commit message) should follow the format "<target>: <summary>"',
  24. commit=commit)
  25. def test_shortlog_length(self):
  26. for commit in Shortlog.commits:
  27. # no reason to re-check on revert shortlogs
  28. shortlog = commit.shortlog
  29. if shortlog.startswith('Revert "'):
  30. continue
  31. l = len(shortlog)
  32. if l > maxlength:
  33. self.fail('Edit shortlog so that it is %d characters or less (currently %d characters)' % (maxlength, l),
  34. commit=commit)