forked from OSGeo/gdal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_log_feature_release.py
executable file
·62 lines (51 loc) · 1.84 KB
/
generate_log_feature_release.py
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
#!/usr/bin/python
import os
import sys
if len(sys.argv) == 1:
VERSION = open("VERSION", "rt").read()
VERSION = VERSION.split(".")
last_release_branch = "%d.%d" % (int(VERSION[0]), int(VERSION[1]) - 1)
else:
last_release_branch = sys.argv[1]
print("Generating /tmp/log.txt with changes not in %s branch" % last_release_branch)
os.system(
f'git log --reverse -v v{last_release_branch}.0..HEAD . ":(exclude)autotest" ":(exclude)doc" ":(exclude).github" > /tmp/log_raw.txt'
)
os.system(
f'git log --no-merges --reverse -v v{last_release_branch}.0..release/{last_release_branch} . ":(exclude)autotest" ":(exclude)doc" ":(exclude).github" > /tmp/log_bugfixes.txt'
)
class Commit:
def __init__(self):
self.metadata = ""
self.message = ""
def get_commits(filename):
commits = []
commit = None
for l in open(filename, "rt").readlines():
if l.startswith("commit "):
commit = Commit()
commits.append(commit)
commit.metadata += l
elif commit.message == "" and l == "\n":
commit.message += l
elif commit.message == "":
commit.metadata += l
else:
commit.message += l
return commits
raw_commits = get_commits("/tmp/log_raw.txt")
bugfixes_commits = get_commits("/tmp/log_bugfixes.txt")
set_bugfixes_commit_messages = set()
for commit in bugfixes_commits:
set_bugfixes_commit_messages.add(commit.message)
with open("/tmp/log.txt", "wt") as f:
for commit in raw_commits:
is_bugfix = False
message = commit.message.split("\n")[1]
for bugfix_commit_message in set_bugfixes_commit_messages:
if message in bugfix_commit_message:
is_bugfix = True
break
if not is_bugfix:
f.write(commit.metadata)
f.write(commit.message)