[Libreoffice-commits] dev-tools.git: scripts/gerrit-filter-domain

Miklos Vajna vmiklos at collabora.co.uk
Fri Jan 10 09:29:49 PST 2014


 scripts/gerrit-filter-domain |   86 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)

New commits:
commit e3ff3fa2032839d62739cfaa323dbf7d0352cdc7
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jan 10 18:28:55 2014 +0100

    scripts: add a gerrit script that can filter by domain
    
    Change-Id: I1cd353f9f4db45fa1c9dafadd7fec14b9028f2ae

diff --git a/scripts/gerrit-filter-domain b/scripts/gerrit-filter-domain
new file mode 100755
index 0000000..4e5f78f
--- /dev/null
+++ b/scripts/gerrit-filter-domain
@@ -0,0 +1,86 @@
+#!/usr/bin/env python3
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# Simple script that tries to do more than a simple query:
+# - can filter for the owner's domains (e.g. you can filter for gmail.com to see volunteer patches)
+# - can exclude areas you're not familiar with
+#
+
+import json
+import subprocess
+import sys
+
+
+def dumpChange(change):
+    print(json.dumps(change, sort_keys=True, indent=4, separators=(',', ': ')))
+
+
+def filterDomain(changes, domain):
+    ret = []
+    for i in changes:
+        if i['owner']['email'].endswith(domain):
+            ret.append(i)
+    return ret
+
+
+def main(argv):
+    domain = argv[0]
+    blacklist = argv[1:]
+    buf = subprocess.check_output(['ssh', 'logerrit', 'gerrit', 'query', 'status:open', '--format', 'JSON', '--all-approvals', '--files'])
+    changes = []
+    for line in buf.decode('utf-8').split('\n'):
+        i = json.loads(line)
+        if 'type' in i:
+            break
+        changes.append(i)
+    changes.sort(key=lambda i: int(i['number']))
+    domainChanges = filterDomain(changes, domain)
+
+    skippedChanges = []
+    for i in domainChanges:
+        skip = False
+
+        files = (set([fileobj['file'] for pset in i['patchSets'] for fileobj in pset['files']]))
+        files.remove('/COMMIT_MSG')
+
+        try:
+            for j in files:
+                for k in blacklist:
+                    if k in j:
+                        skippedChanges.append((i, k))
+                        skip = True
+                        break
+                if skip:
+                    break
+            for j in i['patchSets'][-1]['approvals']:
+                if j['value'] == "-1":
+                    skippedChanges.append((i, "-1 review"))
+                    skip = True
+                    break
+        except:
+            pass
+        if skip:
+            continue
+        print("http://gerrit.libreoffice.org/%s [%s] %s" % (i['number'], i['branch'], i['subject']))
+        print("Changed files: %s" % ', '.join(files))
+        print()
+    print("Found %s changes to review" % (len(domainChanges) - len(skippedChanges)))
+    print()
+    print("Skipped %s changes:" % len(skippedChanges))
+    for i in skippedChanges:
+        print("%s: %s" % (i[0]['number'], i[1]))
+
+if __name__ == "__main__":
+    try:
+        main(sys.argv[1:])
+    except IndexError:
+        print("Usage: gerrit-filter-domain @example.com [exclude-path-pattern1, exclude-path-pattern2, ...]")
+        print()
+        print("Example: gerrit-filter-domain @gmail.com chart")
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab:


More information about the Libreoffice-commits mailing list