1 |
commit: e6c4d9a4da903a2c4d1f190089bed7e365d28f39 |
2 |
Author: Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Feb 2 16:47:36 2012 +0000 |
4 |
Commit: Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Feb 2 16:47:36 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=e6c4d9a4 |
7 |
|
8 |
Working implementation of maintainer-timeout. |
9 |
|
10 |
--- |
11 |
common.py | 5 +++++ |
12 |
maintainer-timeout.py | 25 +++++++++++++++++++++++-- |
13 |
2 files changed, 28 insertions(+), 2 deletions(-) |
14 |
|
15 |
diff --git a/common.py b/common.py |
16 |
index d6841fb..ad25ad8 100644 |
17 |
--- a/common.py |
18 |
+++ b/common.py |
19 |
@@ -2,6 +2,7 @@ |
20 |
# Distributed under the terms of the GNU General Public License v2 |
21 |
|
22 |
import cStringIO |
23 |
+import datetime |
24 |
import re |
25 |
|
26 |
import portage |
27 |
@@ -50,6 +51,7 @@ class Bug: |
28 |
self.__depends_on = [int(dep.text) for dep in xml.findall("dependson")] |
29 |
self.__comments = [c.find("who").text + "\n" + c.find("thetext").text for c in xml.findall("long_desc")] |
30 |
self.__cc = [cc.text for cc in xml.findall("cc")] |
31 |
+ self.__creation_timestamp = datetime.datetime.strptime(xml.find('creation_ts').text, '%Y-%m-%d %H:%M:%S +0000') |
32 |
|
33 |
self.__keywords = [] |
34 |
keywords_elem = xml.find("keywords") |
35 |
@@ -92,6 +94,9 @@ class Bug: |
36 |
def cc(self): |
37 |
return self.__cc |
38 |
|
39 |
+ def creation_timestamp(self): |
40 |
+ return self.__creation_timestamp |
41 |
+ |
42 |
def keywords(self): |
43 |
return self.__keywords |
44 |
|
45 |
|
46 |
diff --git a/maintainer-timeout.py b/maintainer-timeout.py |
47 |
index c75edd6..ee096c4 100755 |
48 |
--- a/maintainer-timeout.py |
49 |
+++ b/maintainer-timeout.py |
50 |
@@ -2,6 +2,7 @@ |
51 |
# Copyright 2012 Gentoo Foundation |
52 |
# Distributed under the terms of the GNU General Public License v2 |
53 |
|
54 |
+import datetime |
55 |
import optparse |
56 |
|
57 |
import bugz.bugzilla |
58 |
@@ -17,6 +18,7 @@ class MyBugz(bugz.bugzilla.Bugz): |
59 |
|
60 |
if __name__ == "__main__": |
61 |
parser = optparse.OptionParser() |
62 |
+ parser.add_option("--days", dest="days", type=int, default=30, help="Number of days after maintainer timeout occurs.") |
63 |
(options, args) = parser.parse_args() |
64 |
if args: |
65 |
parser.error("unrecognized command-line args") |
66 |
@@ -31,6 +33,7 @@ if __name__ == "__main__": |
67 |
for chunk in chunks(raw_bugs, 100): |
68 |
bugs += [Bug(xml) for xml in bugzilla.get([bug['bugid'] for bug in chunk]).findall("bug")] |
69 |
for bug in bugs: |
70 |
+ # Skip bugs where stabilization seems to be already in progress. |
71 |
if 'STABLEREQ' in bug.keywords(): |
72 |
continue |
73 |
arch_found = False |
74 |
@@ -40,12 +43,30 @@ if __name__ == "__main__": |
75 |
break |
76 |
if arch_found: |
77 |
continue |
78 |
+ |
79 |
+ # Skip bugs with comments, they may indicate objections or problem reports. |
80 |
if len(bug.comments()) > 1: |
81 |
continue |
82 |
+ |
83 |
+ # Skip too recent bugs. |
84 |
+ if datetime.datetime.now() - bug.creation_timestamp() < datetime.timedelta(days=options.days): |
85 |
+ continue |
86 |
+ |
87 |
bug.detect_cpvs() |
88 |
if len(bug.cpvs()) != 1: |
89 |
continue |
90 |
+ target_keywords = set() |
91 |
cp = portage.versions.cpv_getkey(bug.cpvs()[0]) |
92 |
for cpv in portage.portdb.cp_list(cp): |
93 |
- print portage.portdb.aux_get(cpv, ['KEYWORDS']) |
94 |
- print (bug.id_number(), bug.summary(), cp) |
95 |
+ for keyword in portage.portdb.aux_get(cpv, ['KEYWORDS'])[0].split(): |
96 |
+ if '~' not in keyword and '-' not in keyword: |
97 |
+ target_keywords.add(keyword) |
98 |
+ bugzilla.modify( |
99 |
+ bug.id_number(), |
100 |
+ comment='Maintainer timeout (%d days). Arches please go ahead.' % options.days, |
101 |
+ add_cc=['%s@g.o' % k for k in target_keywords], |
102 |
+ keywords='STABLEREQ') |
103 |
+ print 'Updated bug #%d (%s). Target KEYWORDS: %s ;-)' % ( |
104 |
+ bug.id_number(), |
105 |
+ bug.summary(), |
106 |
+ ', '.join(list(target_keywords))) |