-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathverify-patches-applied.py
More file actions
executable file
·50 lines (43 loc) · 1.41 KB
/
verify-patches-applied.py
File metadata and controls
executable file
·50 lines (43 loc) · 1.41 KB
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
#!/usr/bin/env python3
import re
import os
import sys
import glob
import subprocess
mesondir = sys.argv[1]
branch = sys.argv[2]
out = subprocess.check_output(['git', '-C', mesondir, 'tag', '--list', branch + '.*'],
universal_newlines=True)
tags = sorted(out.split())
last_tag = tags[-1]
out = subprocess.check_output(['git', '-C', mesondir, 'log', '--oneline', '{}..{}'.format(last_tag, branch)],
universal_newlines=True)
# Get the list of commit message subjects (untruncated)
commits = set()
for line in out.split('\n'):
if not line:
continue
commits.add(line.split(' ', maxsplit=1)[1])
patches = glob.glob('patches/done/*.patch')
if not patches:
print('No patches found?')
exit(1)
# Get the list of commit message subjects from patches (truncated to 71 cols)
patch_infos = {}
for patch in patches:
with open(patch, 'r') as f:
for line in f.readlines():
if not line.startswith('Subject: [PATCH'):
continue
msg = re.split('^Subject: \[PATCH[0-9/ ]*\] ', line, maxsplit=1)[1][:-1]
patch_infos[msg] = patch
for msg, patch in patch_infos.items():
if msg in commits:
continue
for commit in commits:
# msg is truncated, so maybe it won't match exactly
if msg in commit:
break
else:
print('{} in {}'.format(msg, patch))
print('All checked!')