diff options
author | Maxim Uvarov <maxim.uvarov@linaro.org> | 2017-06-13 17:07:33 +0300 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2017-06-13 17:16:25 +0300 |
commit | 3c1f2f715f39c598ffbcb1fcb8666134e8ef531a (patch) | |
tree | 8a493db42800773047ee0196a7bcb6dac7a8efa4 | |
parent | 36f293480c67d12f2f0db4b3a8c6224b6632f184 (diff) |
bugzilla: filter out branch for submision
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
-rwxr-xr-x | gh-hook-bugzilla.py | 35 | ||||
-rw-r--r-- | gscripts_config.py | 5 |
2 files changed, 34 insertions, 6 deletions
diff --git a/gh-hook-bugzilla.py b/gh-hook-bugzilla.py index a1991e9..a13eeb4 100755 --- a/gh-hook-bugzilla.py +++ b/gh-hook-bugzilla.py @@ -18,15 +18,27 @@ from StringIO import StringIO import sys, urllib from cgi import parse_qs, escape import re +import os +import sys + +configfile = '~/gscripts_config.py' +sys.path.append(os.path.dirname(os.path.expanduser(configfile))) +import gscripts_config as gcfg + +blogin = gcfg.gcfg['bugz']['login'] +bpassword = gcfg.gcfg['bugz']['pass'] +print ("%s" % blogin) qin = sys.stdin.read() -f = open('python_%s.dump' % time.time(), 'w') -pickle.dump(qin, f) -f.close() +#f = open('python_%s.dump' % time.time(), 'w') +#pickle.dump(qin, f) +#f.close() -#fname = "python_1492447091.72.dump" +#fname = "test.dump" #qin = pickle.load( open(fname, "rb" ) ) +use_refs=['refs/heads/master'] + def msg_has_bug(msg): buglist = set() print("%s\n" % msg) @@ -52,7 +64,7 @@ URL = "https://bugs.linaro.org" bzapi = bugzilla.Bugzilla(URL) if not bzapi.logged_in: - bzapi.login("login@linaro.org", "password") + bzapi.login(blogin, bpassword) print("Content-type: text/html\n") print("""<!DOCTYPE HTML> @@ -66,11 +78,22 @@ print("""<!DOCTYPE HTML> io = StringIO(qin) js = json.load(io) +found = 0 +for ref in use_refs: + if ref == js["ref"]: + found = 1 + break; +if not found: + print("<h1>ref %s is not posted to bugs</h1>" % js["ref"]) + print("</body></html>") + sys.exit(0) + for c in js["commits"]: bugset = msg_has_bug(c["message"]) for bugnum in bugset: bug = bzapi.getbug(bugnum) - bug_msg = "%s\n%s\n%s %s\n%s\n" % (c["url"], + bug_msg = "%s\n%s\n%s\n%s %s\n%s\n" % (c["url"], + js["ref"], c["timestamp"], c["author"]["name"], c["author"]["email"], c["message"]) diff --git a/gscripts_config.py b/gscripts_config.py new file mode 100644 index 0000000..1475e4b --- /dev/null +++ b/gscripts_config.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python + +print "Using config: %s" % __name__ + +gcfg = {'bugz': {"login": "my_login", "pass": "my_password"}} |