From 6f4f2df3a6f80cd8c189b44b0bc1529c43ec9fd1 Mon Sep 17 00:00:00 2001 From: Ginger <75683114+gingerindustries@users.noreply.github.com> Date: Thu, 7 Dec 2023 13:38:06 +0000 Subject: [PATCH] Keep commits with no title from causing an error --- vyxalbot2/github/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vyxalbot2/github/__init__.py b/vyxalbot2/github/__init__.py index 99e092a..8aecc49 100644 --- a/vyxalbot2/github/__init__.py +++ b/vyxalbot2/github/__init__.py @@ -175,7 +175,11 @@ async def onPushAction(self, event: GitHubEvent): user = formatUser(event.data["sender"]) else: user = event.data["pusher"]["name"] - yield f"{user} {verb}ed a [commit]({commit['url']}) to {formatRef(branch, event.data['repository'])} in {formatRepo(event.data['repository'])}: {commit['message'].splitlines()[0]}" + if len(commit["message"]) < 1: + message = "(no title)" + else: + message = commit['message'].splitlines()[0] + yield f"{user} {verb}ed a [commit]({commit['url']}) to {formatRef(branch, event.data['repository'])} in {formatRepo(event.data['repository'])}: {message}" else: counter = Counter() userCommits = defaultdict(lambda: []) @@ -189,7 +193,11 @@ async def onPushAction(self, event: GitHubEvent): commits = userCommits[user] if user == event.data["sender"]["login"]: user = formatUser(event.data["sender"]) - yield f"{user} {verb}ed {count} commits ([s]({commits[0]['url']}) [e]({commits[-1]['url']})) to {formatRef(branch, event.data['repository'])} in {formatRepo(event.data['repository'])}: {commits[-1]['message'].splitlines()[0]}" + if len(commits[-1]["message"]) < 1: + message = "(no title)" + else: + message = commits[-1]['message'].splitlines()[0] + yield f"{user} {verb}ed {count} commits ([s]({commits[0]['url']}) [e]({commits[-1]['url']})) to {formatRef(branch, event.data['repository'])} in {formatRepo(event.data['repository'])}: {message}" @wrap async def onIssueAction(self, event: GitHubEvent):