-
Notifications
You must be signed in to change notification settings - Fork 5
/
patches
executable file
·100 lines (80 loc) · 1.81 KB
/
patches
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env python
#
import getopt
import string
import sys
import os
def is_git_commit(token):
if (len(token) != 40):
return False;
for c in token:
f = string.find(string.hexdigits, c);
if f == -1:
return False;
return True;
def find_committer(line):
domains = set(['suse.de', 'suse.cz', 'suse.com', 'novell.com']);
tokens = line.split(' ');
for item in tokens:
item = item.strip(' <>\t\n\r');
pos = item.find('@');
if (pos == -1):
continue;
account, domain = item.split('@', 1);
if (domain in domains):
return item;
return '';
def parse_patch_file(file_name):
fd = open(file_name, 'r');
temp_list = list();
committer = 'Unknown';
for line in fd:
if line == '---\n':
break;
parts = line.split(':', 1);
if (len(parts) < 2):
continue;
token = parts.pop(0);
token = token.upper();
if (token == 'GIT-COMMIT'):
for token in parts.pop(0).split():
if is_git_commit(token):
temp_list.append(token);
break;
elif token in ('SIGNED-OFF-BY', 'ACKED-BY', 'REVIEWED-BY',):
email = find_committer(parts.pop(0));
if (len(email) > 0):
committer = email;
fd.close();
ret = list();
for item in temp_list:
print item + str(",") + committer;
return ret;
def do_commit_series(argv):
if (len(argv) < 1):
series_file = "series.conf";
else:
series_file = argv.pop(0);
fd = open(series_file, 'r');
patch_files = list();
for line in fd:
line = line.strip();
if (len(line) == 0 or line[0] == '#'):
continue;
parts = line.split(' ');
for part in parts:
if os.path.isfile(part):
patch_files.append(part);
break;
fd.close();
for patch in patch_files:
parse_patch_file(patch);
return 0;
def main():
sys.argv.pop(0)
return do_commit_series(sys.argv);
if __name__ == '__main__':
ret = main()
if (ret > 255):
ret = 1
sys.exit(ret)