Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git

Adds summary line for diff LoC deltas

Author Dave Jarvis <email>
Date 2026-02-20 17:35:46 GMT-0800
Commit 37ab40875716f3ffe77107d9af906ec3be1971ac
Parent 2291fd1
pages/DiffPage.php
$diffNet = $added - $deleted;
- $diffMsg = '0 lines changed';
$pluralize = function( int $count ): string {
$suffix = '';
if( $count !== 1 ) {
$suffix = 's';
}
return $count . ' line' . $suffix;
};
-
- if( $diffNet > 0 ) {
- $diffMsg = $pluralize( $diffNet ) . ' added';
- } elseif( $diffNet < 0 ) {
- $diffMsg = $pluralize( abs( $diffNet ) ) . ' removed';
- }
- echo '<tr>' .
- '<th class="commit-info-label">Added</th>' .
- '<td class="commit-info-value">' .
- $pluralize( $added ) . '</td></tr>';
+ $deltaMsg = $pluralize( $added ) . ' added, ' .
+ $pluralize( $deleted ) . ' removed';
- echo '<tr>' .
- '<th class="commit-info-label">Deleted</th>' .
- '<td class="commit-info-value">' .
- $pluralize( $deleted ) . '</td></tr>';
+ if( $diffNet === 0 ) {
+ $deltaMsg .= ', 0 lines changed';
+ } elseif( $added > 0 && $deleted > 0 ) {
+ if( $diffNet > 0 ) {
+ $deltaMsg .= ', ' . $diffNet . '-line increase';
+ } else {
+ $deltaMsg .= ', ' . abs( $diffNet ) . '-line decrease';
+ }
+ }
echo '<tr>' .
- '<th class="commit-info-label">Total</th>' .
+ '<th class="commit-info-label">Delta</th>' .
'<td class="commit-info-value">' .
- $diffMsg . '</td></tr>';
+ $deltaMsg . '</td></tr>';
echo '</tbody></table></div></div>';
Delta 13 lines added, 17 lines removed, 4-line decrease