Internals: Recogize "fixes" strings in `log-changes`
This commit is contained in:
parent
c3cd379fd5
commit
78d27842cf
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# mypy: disallow-untyped-defs
|
# mypy: disallow-untyped-defs
|
||||||
# pylint: disable=C0114,C0116,C0209,R0911,R0912,R0915
|
# pylint: disable=C0114,C0116,C0209,R0911,R0912,R0914,R0915
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
@ -13,17 +13,17 @@ import re
|
||||||
|
|
||||||
def message_section(msg: str) -> int:
|
def message_section(msg: str) -> int:
|
||||||
"""Return sorting-section number for given commit message"""
|
"""Return sorting-section number for given commit message"""
|
||||||
if re.match(r'^Support', msg):
|
if re.match(r'^Support', msg, flags=re.IGNORECASE):
|
||||||
return 10
|
return 10
|
||||||
if re.match(r'^Add', msg):
|
if re.match(r'^Add', msg, flags=re.IGNORECASE):
|
||||||
return 20
|
return 20
|
||||||
if re.match(r'^Improve', msg):
|
if re.match(r'^Improve', msg, flags=re.IGNORECASE):
|
||||||
return 30
|
return 30
|
||||||
if re.match(r'^Fix', msg):
|
if re.match(r'^Fix', msg, flags=re.IGNORECASE):
|
||||||
return 40
|
return 40
|
||||||
if re.match(r'^(Internals|CI|Tests)', msg):
|
if re.match(r'^(Internals|CI|Tests)', msg, flags=re.IGNORECASE):
|
||||||
return -1
|
return -1
|
||||||
if re.match(r'^Bump.* from .* to .*', msg): # dependabot
|
if re.match(r'^Bump.* from .* to .*', msg, flags=re.IGNORECASE): # dependabot
|
||||||
return -1
|
return -1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
@ -32,15 +32,20 @@ def process() -> None:
|
||||||
cmd = "git log"
|
cmd = "git log"
|
||||||
|
|
||||||
msgs = {}
|
msgs = {}
|
||||||
|
msg_authors = {}
|
||||||
with os.popen(cmd) as fh:
|
with os.popen(cmd) as fh:
|
||||||
author = ""
|
author = ""
|
||||||
lineno = 0
|
lineno = 0
|
||||||
|
key = None
|
||||||
for line in fh:
|
for line in fh:
|
||||||
lineno += 1
|
lineno += 1
|
||||||
line = line.rstrip()
|
line = line.rstrip()
|
||||||
|
# print("l %s" % line)
|
||||||
if re.match(r'^Date', line):
|
if re.match(r'^Date', line):
|
||||||
|
key = None
|
||||||
continue
|
continue
|
||||||
if re.match(r'^commit', line):
|
if re.match(r'^commit', line):
|
||||||
|
key = None
|
||||||
continue
|
continue
|
||||||
if re.search(r'Commentary: Changes update', line):
|
if re.search(r'Commentary: Changes update', line):
|
||||||
break
|
break
|
||||||
|
|
@ -59,9 +64,6 @@ def process() -> None:
|
||||||
|
|
||||||
elif author != "" and dm:
|
elif author != "" and dm:
|
||||||
msg = dm.group(1)
|
msg = dm.group(1)
|
||||||
if not re.search(r'\.$', msg):
|
|
||||||
msg += '.'
|
|
||||||
msg += ' [' + author + ']'
|
|
||||||
|
|
||||||
mid = re.search(r'\(#([0-9][0-9][0-9][0-9]+)', line)
|
mid = re.search(r'\(#([0-9][0-9][0-9][0-9]+)', line)
|
||||||
if mid:
|
if mid:
|
||||||
|
|
@ -73,10 +75,19 @@ def process() -> None:
|
||||||
if section >= 0:
|
if section >= 0:
|
||||||
key = "%06s_%06s_%06d" % (section, bug_id, lineno)
|
key = "%06s_%06s_%06d" % (section, bug_id, lineno)
|
||||||
msgs[key] = '* ' + msg
|
msgs[key] = '* ' + msg
|
||||||
# print("i [%s] %s" % (key, msg))
|
msg_authors[key] = author
|
||||||
|
# print("i [%s] %s [%s]" % (key, msg, author))
|
||||||
|
|
||||||
author = ""
|
author = ""
|
||||||
|
|
||||||
|
elif key:
|
||||||
|
m = re.search(r'(fix|fixes) *#\(?([0-9][0-9][0-9][0-9]+)',
|
||||||
|
line,
|
||||||
|
flags=re.IGNORECASE)
|
||||||
|
if m:
|
||||||
|
# print("K %s" % line)
|
||||||
|
msgs[key] += ' (#' + m.group(2) + ')'
|
||||||
|
|
||||||
if not msgs:
|
if not msgs:
|
||||||
print("No Changes need to be inserted.")
|
print("No Changes need to be inserted.")
|
||||||
return
|
return
|
||||||
|
|
@ -89,7 +100,10 @@ def process() -> None:
|
||||||
for key in sorted(msgs.keys()):
|
for key in sorted(msgs.keys()):
|
||||||
if msgs[key] not in dedup:
|
if msgs[key] not in dedup:
|
||||||
dedup[msgs[key]] = True
|
dedup[msgs[key]] = True
|
||||||
print(msgs[key])
|
msg = msgs[key]
|
||||||
|
if not re.search(r'\.$', msg):
|
||||||
|
msg += '.'
|
||||||
|
print(msg + ' [' + msg_authors[key] + ']')
|
||||||
|
|
||||||
print()
|
print()
|
||||||
print("You may now want to clean up spelling, and commit:")
|
print("You may now want to clean up spelling, and commit:")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue