From 6742354c7239c42b5eff3fe99117188dcde00440 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@gmail.com>
Date: Fri, 9 Apr 2021 09:42:01 +0200
Subject: [PATCH] =?UTF-8?q?Issue=C2=A0#6=20-=20list=20of=20bugs=20applied?=
 =?UTF-8?q?=20must=20be=20global?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

https://bugs.koha-community.org/show_bug.cgi?id=28608
Signed-off-by: hakam <hakam@inlibro.com>
---
 git-bz | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/git-bz b/git-bz
index 2a1fbb3..de89eb7 100755
--- a/git-bz
+++ b/git-bz
@@ -115,6 +115,7 @@ import string
 
 # options dictionary from optparse
 global_options = None
+bugs_applied = []
 
 # Utility functions for git
 # =========================
@@ -1739,7 +1740,6 @@ def do_apply(*args):
         print("No patches on bug %d" % bug.id)
         return
 
-    bugs_applied = []
     patches = []
     patches_by_id = {}
     for patch in bug.patches:
@@ -1753,6 +1753,10 @@ def do_apply(*args):
         for d_id in dependencies:
             if d_id == '':
                 continue
+
+            if d_id in bugs_applied:
+                continue
+
             dep_bug = Bug.load(BugHandle.parse_or_die(d_id),
                            attachmentdata=False)
             s = dep_bug.bug_status
@@ -1882,7 +1886,7 @@ FIXME: need commit message.
         add_url(bug, commits)
 
     bugs_applied.append(bug_ref)
-    return bugs_applied
+    return bug_ref
 
 def strip_bug_url(bug, commit_body):
     # Strip off the trailing bug URLs we add with -u; we do this before
@@ -2702,7 +2706,6 @@ if len(args) < min_args or len(args) > max_args:
 if command == 'add-url':
     do_add_url(*args)
 elif command == 'apply':
-    bugs_applied = []
     if not args:
         # continue, skip or abort
         do_apply(*args)
@@ -2715,7 +2718,6 @@ elif command == 'apply':
         if applied is None:
             break
 
-        bugs_applied.extend(applied)
 elif command == 'attach':
     do_attach(*args)
 elif command == 'components':
-- 
2.25.1