##// END OF EJS Templates
check-commit: sort errors by line number
timeless -
r27783:1d095371 default
parent child Browse files
Show More
@@ -48,28 +48,35 b' def nonempty(first, second):'
48 def checkcommit(commit, node = None):
48 def checkcommit(commit, node = None):
49 exitcode = 0
49 exitcode = 0
50 printed = node is None
50 printed = node is None
51 hits = []
51 for exp, msg in errors:
52 for exp, msg in errors:
52 m = re.search(exp, commit)
53 m = re.search(exp, commit)
53 if m:
54 if m:
54 pos = 0
55 end = m.end()
55 end = m.end()
56 trailing = re.search(r'(\\n)+$', exp)
56 trailing = re.search(r'(\\n)+$', exp)
57 if trailing:
57 if trailing:
58 end -= len(trailing.group()) / 2
58 end -= len(trailing.group()) / 2
59 last = ''
59 hits.append((end, exp, msg))
60 for n, l in enumerate(commit.splitlines(True)):
60 if hits:
61 pos += len(l)
61 hits.sort()
62 pos = 0
63 last = ''
64 for n, l in enumerate(commit.splitlines(True)):
65 pos += len(l)
66 while len(hits):
67 end, exp, msg = hits[0]
62 if pos < end:
68 if pos < end:
63 last = nonempty(l, last)
64 else:
65 if not printed:
66 printed = True
67 print "node: %s" % node
68 print "%d: %s" % (n, msg)
69 print " %s" % nonempty(l, last)[:-1]
70 if "BYPASS" not in os.environ:
71 exitcode = 1
72 break
69 break
70 if not printed:
71 printed = True
72 print "node: %s" % node
73 print "%d: %s" % (n, msg)
74 print " %s" % nonempty(l, last)[:-1]
75 if "BYPASS" not in os.environ:
76 exitcode = 1
77 del hits[0]
78 last = nonempty(l, last)
79
73 return exitcode
80 return exitcode
74
81
75 def readcommit(node):
82 def readcommit(node):
@@ -55,15 +55,15 b' A patch with lots of errors:'
55 > if opts.get('all'):
55 > if opts.get('all'):
56 > EOF
56 > EOF
57 $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit
57 $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit
58 7: (BC) needs to be uppercase
58 1: username is not an email address
59 # User timeless
60 7: summary keyword should be most user-relevant one-word command or topic
59 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
61 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
60 7: no space allowed between issue and number
62 7: (BC) needs to be uppercase
61 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
63 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
62 7: use (issueDDDD) instead of bug
64 7: use (issueDDDD) instead of bug
63 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
65 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
64 1: username is not an email address
66 7: no space allowed between issue and number
65 # User timeless
66 7: summary keyword should be most user-relevant one-word command or topic
67 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
67 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
68 7: summary line too long (limit is 78)
68 7: summary line too long (limit is 78)
69 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
69 transplant/foo: this summary is way too long use Oxford comma (bc) (bug123) (issue 244)
@@ -96,16 +96,16 b' A patch with other errors:'
96 $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit
96 $ cat patch-with-long-header.diff | $TESTDIR/../contrib/check-commit
97 1: username is not an email address
97 1: username is not an email address
98 # User timeless
98 # User timeless
99 7: summary line doesn't start with 'topic: '
99 7: don't capitalize summary lines
100 This has no topic and ends with a period.
100 This has no topic and ends with a period.
101 7: don't capitalize summary lines
101 7: summary line doesn't start with 'topic: '
102 This has no topic and ends with a period.
102 This has no topic and ends with a period.
103 7: don't add trailing period on summary line
103 7: don't add trailing period on summary line
104 This has no topic and ends with a period.
104 This has no topic and ends with a period.
105 19: adds double empty line
106 +
107 15: adds double empty line
105 15: adds double empty line
108 +
106 +
109 16: adds a function with foo_bar naming
107 16: adds a function with foo_bar naming
110 + def blah_blah(x):
108 + def blah_blah(x):
109 19: adds double empty line
110 +
111 [1]
111 [1]
General Comments 0
You need to be logged in to leave comments. Login now