From 66d30e4ea2300d248ec60dca0585108176974480 Mon Sep 17 00:00:00 2001
From: Skunnyk <skunnyk@alteroot.org>
Date: Sun, 23 Sep 2018 15:56:07 +0200
Subject: [PATCH] Add possibility to import  resolved bugs too

- By using the --resolved switch
- Importing tens of thousands bugs is really slow, I think that's why gnome and fd.o chose to not import resolved bugs.
- However on xfce, it should be doable (only ~15k bugs in total)
---
 bztogl/bztogl.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/bztogl/bztogl.py b/bztogl/bztogl.py
index d65f25f..065a733 100644
--- a/bztogl/bztogl.py
+++ b/bztogl/bztogl.py
@@ -311,7 +311,12 @@ def processbug(bgo, bzurl, instance, resolution, target, user_cache,
 
     # Workaround python-gitlab bug by providing redundant state_event
     # https://github.com/python-gitlab/python-gitlab/pull/389
-    issue.save(state_event='reopen')
+    if bzbug.status.startswith('RESOLVED'):
+      print("Closing the issue in gitlab as it is marked as resolved in bugzilla")
+      issue.state_event = 'close'
+      issue.save()
+    else:
+      issue.save(state_event='reopen')
 
     print("New GitLab issue created from bugzilla bug "
           "{}: {}".format(bzbug.id, issue.web_url))
@@ -355,6 +360,8 @@ def options():
                         help="import for freedesktop.org rather than GNOME")
     parser.add_argument('--xfce', action='store_true',
                         help="import for xfce.org rather than GNOME")
+    parser.add_argument('--resolved', action='store_true',
+                        help="import resolved bugs (default: no)")
     return parser.parse_args()
 
 
@@ -436,6 +443,9 @@ def main():
         print("Querying for open bugs for the '%s' product, all components" %
               args.product)
     query["status"] = "NEW ASSIGNED REOPENED NEEDINFO UNCONFIRMED".split()
+    if args.resolved:
+      print('We are also importing resolved issues')
+      query["status"] += " RESOLVED".split()
     bzbugs = bgo.query(query)
     print("{} bugs found".format(len(bzbugs)))
     count = 0
-- 
GitLab