Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Keep commits with no title from causing an error
Browse files Browse the repository at this point in the history
  • Loading branch information
gingershaped committed Dec 7, 2023
1 parent b00af80 commit 6f4f2df
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions vyxalbot2/github/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: [])
Expand All @@ -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):
Expand Down

0 comments on commit 6f4f2df

Please sign in to comment.