From 45a2f75b8b64722b28aa069edfe12755f30740e8 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 21 Mar 2022 10:28:10 +0100 Subject: [PATCH] webhooks: prevent error on new/removed git refs --- hubsrht/blueprints/webhooks.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hubsrht/blueprints/webhooks.py b/hubsrht/blueprints/webhooks.py index 4cfcfc9..62e75b0 100644 --- a/hubsrht/blueprints/webhooks.py +++ b/hubsrht/blueprints/webhooks.py @@ -105,6 +105,8 @@ def git_repo(repo_id): for ref in payload["refs"]: old = (ref["old"] or {}).get("id") new = (ref["new"] or {}).get("id") + if not old or not new: + continue # New ref, or ref deleted for commit in reversed(git.log(pusher, repo, old, new)): for trailer, value in commit_trailers(commit["message"]): _handle_commit_trailer(trailer, value, pusher, repo, commit)