From 0b7219f27aaa2b503f890fd7dfa7881bc5cecbc6 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 24 Mar 2019 12:00:50 +0100 Subject: [PATCH] Don't crash if a non-master and non-unity branch is pushed to --- webserver.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/webserver.py b/webserver.py index 89c440b7..ba82eba7 100644 --- a/webserver.py +++ b/webserver.py @@ -394,15 +394,18 @@ def hooks_github(): # TODO: add secret check if j["ref"] == "refs/heads/master": message = f"🐙 Nuovi aggiornamenti a Royalnet master:\n" - if j["ref"] == "refs/heads/unity": + elif j["ref"] == "refs/heads/unity": message = f"🐙 Progresso di Royalnet unity:\n" - for commit in j.get("commits", []): - if commit["distinct"]: - message += f'{commit["message"]}' \ - f' di {commit["author"].get("username", "anonimo")}\n' - telegram_bot.send_message(config["Telegram"]["main_group"], message, - parse_mode="HTML", disable_web_page_preview=True, disable_notification=True) - return "Done." + else: + return "Ignored." + if message: + for commit in j.get("commits", []): + if commit["distinct"]: + message += f'{commit["message"]}' \ + f' di {commit["author"].get("username", "anonimo")}\n' + telegram_bot.send_message(config["Telegram"]["main_group"], message, + parse_mode="HTML", disable_web_page_preview=True, disable_notification=True) + return "Done." @app.before_request