From 6bdd0e284f36d97707286a259404d3ffc4076550 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Mon, 11 Jan 2021 21:24:01 +0100 Subject: [PATCH] advertise new branches --- app.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 111c859..2cc04de 100644 --- a/app.py +++ b/app.py @@ -20,6 +20,7 @@ def main(): if data["repository"]["private"]: return "IGN" + if event == "push" and data["commits"] != []: commits = data["commits"] commit_count = f"{len(commits)} commit{'s' if len(commits) > 1 else ''}" @@ -33,9 +34,17 @@ def main(): others = f" (et {len(commits)-1} autres commits)" url_user = make_url_user(data['pusher']) - url_commits = f"[url={data['compare_url']}]{commit_count}[/url]" - msg = f"{url_user} a poussé {url_commits} dans {url_repository} : {message}{others}" + # Ref doesn't have a previous commit = new branch + if all(c == "0" for c in data["before"]) and data["ref"].startswith("refs/heads/"): + branch = data["ref"][11:] + url_branch = data["repository"]["html_url"] + f"/src/branch/{branch}" + url_branch = f"[url={url_branch}]{branch}[/url]" + msg = f"{url_user} a créé une nouvelle branche {url_branch} dans {url_repository}" + # Pre-existing branch + else: + url_commits = f"[url={data['compare_url']}]{commit_count}[/url]" + msg = f"{url_user} a poussé {url_commits} dans {url_repository} : {message}{others}" if event == "push" and data["ref"].startswith("refs/tags/"): url_user = make_url_user(data['pusher'])