aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tatt/dot-tatt-spec4
-rw-r--r--tatt/scriptwriter.py13
-rw-r--r--templates/updatebug46
3 files changed, 57 insertions, 6 deletions
diff --git a/tatt/dot-tatt-spec b/tatt/dot-tatt-spec
index 68ef223..020fbda 100644
--- a/tatt/dot-tatt-spec
+++ b/tatt/dot-tatt-spec
@@ -10,4 +10,6 @@ rdeps=integer(0,512,default=10)
usecombis=integer(0,512,default=12)
repodir=string(default="./gentoo-x86")
tinderbox-url=string(default="http://qa-reports.gentoo.org/output/genrdeps/rindex/")
-safedir=string(default="") \ No newline at end of file
+safedir=string(default="")
+bugzilla-url=string(default="https://bugs.gentoo.org")
+bugzilla-key=string(default="")
diff --git a/tatt/scriptwriter.py b/tatt/scriptwriter.py
index 864f45b..9874217 100644
--- a/tatt/scriptwriter.py
+++ b/tatt/scriptwriter.py
@@ -110,12 +110,15 @@ def writesucessreportscript (job, config):
reportname = (job.name + ".report")
if os.path.isfile(outfilename):
print("WARNING: Will overwrite " + outfilename)
+ try:
+ updatebugtemplate=open(config['template-dir'] + "updatebug", 'r')
+ except IOError:
+ print("updatebug not found in " + config['template-dir'])
+ sys.exit(1)
+ updatebug=updatebugtemplate.read().replace("@@ARCH@@", config['arch'])
+ updatebug=updatebug.replace("@@BUG@@", job.bugnumber)
outfile = open(outfilename,'w')
- outfile.write("#!/bin/sh" + '\n')
- outfile.write("if grep failed " + reportname + " >> /dev/null; then echo Failure found;\n")
- succmess = config['successmessage'].replace("@@ARCH@@", config['arch'])
- outfile.write("else bugz modify " + job.bugnumber + ' -c' + "\"" + succmess + "\";\n")
- outfile.write("fi;")
+ outfile.write(updatebug)
os.fchmod(outfile.fileno(),484)
outfile.close()
print("Success Report script written to " + outfilename)
diff --git a/templates/updatebug b/templates/updatebug
new file mode 100644
index 0000000..25b18a8
--- /dev/null
+++ b/templates/updatebug
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+# Copyright 2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import portage.versions
+import requests
+from tatt.tattConfig import tattConfig as tattConfig
+
+
+def main():
+ tattconfig = tattConfig()
+ session = requests.Session()
+ session.params.update({'Bugzilla_api_key': tattconfig['bugzilla-key']})
+
+ bug_url = tattconfig['bugzilla-url']
+ bug_id = str(@@BUG@@)
+
+ params = {'id': bug_id}
+ response = session.get(tattconfig['bugzilla-url'] + '/rest/bug', params=params).json()['bugs'][0]
+
+ has_my_arch = False
+ has_other_arches = False
+ for cc in response['cc']:
+ body, domain = cc.split('@', 1)
+ if domain == 'gentoo.org':
+ if body == '@@ARCH@@':
+ has_my_arch = True
+ elif body in portage.archlist:
+ has_other_arches = True
+
+ # We don't close bugs which still have other arches for obvious reasons,
+ # and security bugs because stabilization is not the last step for them.
+ params['cc'] = {}
+ params['cc']['remove'] = ['@@ARCH@@@gentoo.org']
+ params['comment'] = {}
+ if has_other_arches or 'Security' in response['product']:
+ params['comment']['body'] = '@@ARCH@@ stable'
+ else:
+ params['comment']['body'] = '@@ARCH@@ stable, closing'
+ params['status'] = 'RESOLVED'
+ params['resolution'] = 'FIXED'
+
+ session.put(tattconfig['bugzilla-url'] + '/rest/bug/' + bug_id, json=params)
+
+if __name__ == '__main__':
+ main()