Skip to content

Commit

Permalink
src/webhooks.py: Limit push commit listing to 2000 chars
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrxyz committed Nov 26, 2024
1 parent fdaad43 commit e269d8c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,14 @@ async def push(self, payload: ClientPayload):
)
# ignore webhooks with zero commits
elif commit_count > 1:
formatted_commits = [
f"* [`{commit['id'][:7]}`]({self.url(commit)}): \"{self.natural_wrap(commit['message'])[:100]}\""
for commit in gh["commits"]
]
formatted_commits = []
for commit in gh["commits"]:
message = f"* [`{commit['id'][:7]}`]({self.url(commit)}): \"{self.natural_wrap(commit['message'])[:100]}\""
if (
sum(len(line) for line in formatted_commits) + len(message)
< 2000
):
formatted_commits.append(message)
formatted_commits_str = "\n".join(formatted_commits)
await updates_channel.send(
f"{name} {pushed} {commit_count} commits to {branch} in {repo} ({compare}):\n{formatted_commits_str}",
Expand Down

0 comments on commit e269d8c

Please sign in to comment.