Skip to content

Commit 6a51e1d

Browse files
committed
updates improving commit notifications removing redundant by author part when all commit owners match the pusher
1 parent 55cdc5d commit 6a51e1d

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

web/github.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,20 @@
153153
$Commits = [];
154154

155155
if (!empty($Message['commits'])) {
156+
$PusherName = $Msg['alias'] ?? '';
157+
$AllSameAuthor = array_reduce($Message['commits'], function (bool $carry, array $c) use ($PusherName): bool {
158+
return $carry && (($c['author']['name'] ?? '') === $PusherName);
159+
}, true);
160+
156161
foreach ($Message['commits'] as $Commit) {
157162
$CommitMsg = strtok($Commit['message'], "\n");
158163
$FileCounts = [];
159164
if (!empty($Commit['added'])) $FileCounts[] = '+' . count($Commit['added']);
160165
if (!empty($Commit['modified'])) $FileCounts[] = '~' . count($Commit['modified']);
161166
if (!empty($Commit['removed'])) $FileCounts[] = '-' . count($Commit['removed']);
162167
$FileInfo = !empty($FileCounts) ? ' _(' . implode(' ', $FileCounts) . ' files)_' : '';
163-
$Commits[] = "• [" . substr($Commit['id'], 0, 7) . "]({$Commit['url']}) _{$CommitMsg}_ "
164-
. "by {$Commit['author']['name']}{$FileInfo}";
168+
$ByAuthor = $AllSameAuthor ? '' : " by {$Commit['author']['name']}";
169+
$Commits[] = "• [" . substr($Commit['id'], 0, 7) . "]({$Commit['url']}) _{$CommitMsg}_{$ByAuthor}{$FileInfo}";
165170
}
166171
}
167172

0 commit comments

Comments
 (0)