From 9561a01b61793a3be86c355f9350522397711d02 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Wed, 21 Oct 2020 17:42:30 +0200 Subject: [PATCH] commit pluralization and new issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * "1 autres commits" -> "1 autre commit" * " un ticket" -> "créé un ticket" --- app.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index e46e247..111c859 100644 --- a/app.py +++ b/app.py @@ -24,7 +24,13 @@ def main(): commits = data["commits"] commit_count = f"{len(commits)} commit{'s' if len(commits) > 1 else ''}" message = "[inlinecode]" + commits[0]["message"].split('\n',1)[0] + "[/inlinecode]" - others = f" (et {len(commits)-1} autres commits)" if len(commits) > 1 else "" + + if len(commits) <= 1: + others = "" + elif len(commits) == 2: + others = " (et 1 autre commit)" + else: + 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]" @@ -48,7 +54,7 @@ def main(): if data['action'] == "closed": msg = f"{url_user} a fermé le ticket {url_issue} dans {url_repository}" - elif data['action'] == "created": + elif data['action'] in ["created", "opened"]: msg = f"{url_user} a créé un ticket {url_issue} dans {url_repository}" else: msg = f"{url_user} a <{data['action']}> le ticket {url_issue} dans {url_repository}"