-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-changelog
executable file
·74 lines (64 loc) · 1.9 KB
/
check-changelog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/python
import sys
import re
# Match the <day> <month> <year> format we use to find
# where entries begin
date_format="\d{1,2} \w{3} \d{4}"
# Used in version/revision bumps *foobar-1.0 (date)
date_regex = re.compile(date_format)
# Used in entries with the actual change text
date_regex_semicolon = re.compile("(%s);" % date_format)
# + is used in package names (for example gtk+) so try to handle that
ebuild_regex = re.compile("((,|\s)\+[\S\+]+\.ebuild)")
def check_changelog(file):
f = open(file)
lines = f.readlines()
# All *${P} entries as ${P}
bumps = []
file_printed = False
# Scan the whole file for new entries because with for example moves
# from one category to another we have the ebuilds appearing as new
# ones again
for line in lines:
if line.startswith("*"):
# Check that the date is in valid form
if not date_regex.search(line):
if not file_printed:
print file + ":"
file_printed = True
sys.stdout.write("\tbad date entry for new revision/version entry: " + line)
else:
try:
bumps.append(line[1:line.index(" ")])
except ValueError:
sys.stderr.write("Failure in parsing: " + file + "\n")
n=0
length = len(lines)
while n < length:
line = lines[n]
# Use dates to find separate ChangeLog entries
match = date_regex_semicolon.search(line)
if match:
date = match.group(1)
while True:
for m in ebuild_regex.findall(line):
# remove + and trailing .ebuild
to_find = m[0][2:-7]
if not to_find in bumps:
if not file_printed:
print file + ":"
file_printed = True
print "\tMissing new ebuild entry *" + to_find +" (%s) for addition on line " % date + str(n+1)
n+=1
if line.find(":") >= 0 or n == length:
break
line = lines[n]
n+=1
f.close()
return not file_printed
bad_found = False
for ch in sys.argv[1:]:
if not check_changelog(ch):
bad_found = True
if bad_found:
sys.exit(1)