From 2101d5ab3e8c9973534a72d2f8ce91da8d654948 Mon Sep 17 00:00:00 2001 From: ma Date: Sun, 25 Jul 2021 23:26:30 +0200 Subject: [PATCH 1/3] Introduce check if use_bugzilla_id is enabled If Option use_bugzilla_id is enabled and one of the sudo users is missing required ownership, API silently ignores the iid flag and auto-generates the id. Introduce check if the generated issue id does not match the bugzilla bug id, otherwise such situations arent noticed during migration and things become really messy. --- bugzilla2gitlab/models.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bugzilla2gitlab/models.py b/bugzilla2gitlab/models.py index a36c84e..c2c3849 100644 --- a/bugzilla2gitlab/models.py +++ b/bugzilla2gitlab/models.py @@ -261,6 +261,19 @@ def save(self): return self.id = response["iid"] + + """ + Check if created issue ID matches requested ID if + option to keep numbers is enabled. Otherwise things + can become quite messy + """ + if CONF.use_bugzilla_id is True: + if self.id != self.bug_id: + raise Exception( + "Issue id [{}]!=[{}]: missing owner permission for gitlab user id {}".format( + self.id, self.bug_id, self.sudo + ) + ) print("Created issue with id: {}".format(self.id)) def close(self): From 38ad5d3fbf40dfc09971e53507bb5fa3bcd767d2 Mon Sep 17 00:00:00 2001 From: ma Date: Sun, 25 Jul 2021 23:41:08 +0200 Subject: [PATCH 2/3] convert to int before check --- bugzilla2gitlab/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bugzilla2gitlab/models.py b/bugzilla2gitlab/models.py index c2c3849..5b977c1 100644 --- a/bugzilla2gitlab/models.py +++ b/bugzilla2gitlab/models.py @@ -268,7 +268,7 @@ def save(self): can become quite messy """ if CONF.use_bugzilla_id is True: - if self.id != self.bug_id: + if int(self.id) != int(self.bug_id): raise Exception( "Issue id [{}]!=[{}]: missing owner permission for gitlab user id {}".format( self.id, self.bug_id, self.sudo From a19a11fc0bc0be3342521b552758018fb30b2b58 Mon Sep 17 00:00:00 2001 From: ma Date: Mon, 26 Jul 2021 07:10:22 +0200 Subject: [PATCH 3/3] fix failing format test --- bugzilla2gitlab/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bugzilla2gitlab/models.py b/bugzilla2gitlab/models.py index 5b977c1..d9bf47c 100644 --- a/bugzilla2gitlab/models.py +++ b/bugzilla2gitlab/models.py @@ -271,7 +271,7 @@ def save(self): if int(self.id) != int(self.bug_id): raise Exception( "Issue id [{}]!=[{}]: missing owner permission for gitlab user id {}".format( - self.id, self.bug_id, self.sudo + self.id, self.bug_id, self.sudo ) ) print("Created issue with id: {}".format(self.id))