On 11/9/20 11:09 PM, Jakub Jelinek wrote:
So I think either new_update must be raising an exception, or returning
None for some reason.
Bet we want to add logging for that exception, as well as for it returning
None and inside of it perhaps even more detailed logging on where it
returned None.

The following should expand both a returned None or an exception.
Jakub, please install it.

Thanks,
Martin
>From c3fb1dbededb037875428ced2b66ff40dc45c9d1 Mon Sep 17 00:00:00 2001
From: marxin <mli...@suse.cz>
Date: Tue, 10 Nov 2020 09:22:28 +0100
Subject: [PATCH] another extra logging

---
 .../src-home/git-hooks/hooks/post_receive.py  | 20 +++++++++----------
 .../git-hooks/hooks/updates/factory.py        |  2 ++
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/sourceware/projects/src-home/git-hooks/hooks/post_receive.py b/sourceware/projects/src-home/git-hooks/hooks/post_receive.py
index 37166e6..9386e2f 100644
--- a/sourceware/projects/src-home/git-hooks/hooks/post_receive.py
+++ b/sourceware/projects/src-home/git-hooks/hooks/post_receive.py
@@ -39,17 +39,17 @@ def post_receive_one(ref_name, old_rev, new_rev, refs, submitter_email):
     with open("/tmp/gcc-git-mail.log", "a") as f:
         ts = str(datetime.datetime.now())
         f.write('post_receive_one:%s: ref_name=%s, old_rev=%s, new_rev=%s\n' % (ts, ref_name, old_rev, new_rev))
-    update = new_update(ref_name, old_rev, new_rev, refs, submitter_email)
-    if update is None:
-        # We emit a warning, rather than trigger an assertion, because
-        # it gives the script a chance to process any other reference
-        # that was updated, but not processed yet.
-        warn("post-receive: Unsupported reference update: %s (ignored)."
-             % ref_name,
-             "              old_rev = %s" % old_rev,
-             "              new_rev = %s" % new_rev)
-        return
     try:
+        update = new_update(ref_name, old_rev, new_rev, refs, submitter_email)
+        if update is None:
+            # We emit a warning, rather than trigger an assertion, because
+            # it gives the script a chance to process any other reference
+            # that was updated, but not processed yet.
+            warn("post-receive: Unsupported reference update: %s (ignored)."
+                 % ref_name,
+                 "              old_rev = %s" % old_rev,
+                 "              new_rev = %s" % new_rev)
+            return
         update.send_email_notifications()
     except Exception as e:
         with open("/tmp/gcc-git-mail.log", "a") as f:
diff --git a/sourceware/projects/src-home/git-hooks/hooks/updates/factory.py b/sourceware/projects/src-home/git-hooks/hooks/updates/factory.py
index 663a440..42cf9cc 100644
--- a/sourceware/projects/src-home/git-hooks/hooks/updates/factory.py
+++ b/sourceware/projects/src-home/git-hooks/hooks/updates/factory.py
@@ -207,6 +207,8 @@ def new_update(ref_name, old_rev, new_rev, all_refs, submitter_email):
         raise_unrecognized_ref_name(ref_name)
 
     new_cls = REF_CHANGE_MAP.get((ref_kind, change_type, object_type), None)
+    with open("/tmp/gcc-git-mail.log", "a") as f:
+        f.write('REF_CHANGE_MAP: ref_kind=%s, change_type=%s, object_type=%s, new_cls=%s' % (str(ref_kind), str(change_type), str(object_type), str(new_cls)))
     if new_cls is None:
         return None
 
-- 
2.29.2

Reply via email to