Dave Jarvis' Repositories

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

Updates added/removed counts

Author Dave Jarvis <email>
Date 2026-02-20 17:31:29 GMT-0800
Commit 2291fd1b45999e09b75ea12a484631ada80cf11a
Parent cf3662b
pages/DiffPage.php
if( $line === '' ) {
$isMsg = true;
- continue;
- }
-
- if( $isMsg ) {
+ } elseif( $isMsg ) {
$msg .= $line . "\n";
} else {
if( $hunkLine['t'] === '+' ) {
$added++;
- }
-
- if( $hunkLine['t'] === '-' ) {
+ } elseif( $hunkLine['t'] === '-' ) {
$deleted++;
}
$diffMsg = '0 lines changed';
$pluralize = function( int $count ): string {
- $suffix = $count === 1 ? '' : 's';
+ $suffix = '';
+
+ if( $count !== 1 ) {
+ $suffix = 's';
+ }
return $count . ' line' . $suffix;
}
- private function renderFileDiff( $change ) {
+ private function renderFileDiff( array $change ) {
$statusIcon = 'fa-file';
$statusClass = '';
if( $change['type'] === 'A' ) {
$statusIcon = 'fa-plus-circle';
$statusClass = 'status-add';
- }
-
- if( $change['type'] === 'D' ) {
+ } elseif( $change['type'] === 'D' ) {
$statusIcon = 'fa-minus-circle';
$statusClass = 'status-del';
- }
-
- if( $change['type'] === 'M' ) {
+ } elseif( $change['type'] === 'M' ) {
$statusIcon = 'fa-pencil-alt';
$statusClass = 'status-mod';
echo '<img src="/images/diff-gap.svg" class="diff-gap-icon" />';
echo '</td></tr>';
- continue;
- }
-
- $class = 'diff-ctx';
- $char = ' ';
+ } else {
+ $class = 'diff-ctx';
+ $char = ' ';
- if( $line['t'] === '+' ) {
- $class = 'diff-add';
- $char = '+';
- }
+ if( $line['t'] === '+' ) {
+ $class = 'diff-add';
+ $char = '+';
+ } elseif( $line['t'] === '-' ) {
+ $class = 'diff-del';
+ $char = '-';
+ }
- if( $line['t'] === '-' ) {
- $class = 'diff-del';
- $char = '-';
+ echo '<tr class="' . $class . '">';
+ echo '<td class="diff-num" data-num="' . $line['no'] . '"></td>';
+ echo '<td class="diff-num" data-num="' . $line['nn'] . '"></td>';
+ echo '<td class="diff-code"><span class="diff-marker">' .
+ $char . '</span>' . htmlspecialchars( $line['l'] ) . '</td>';
+ echo '</tr>';
}
-
- echo '<tr class="' . $class . '">';
- echo '<td class="diff-num" data-num="' . $line['no'] . '"></td>';
- echo '<td class="diff-num" data-num="' . $line['nn'] . '"></td>';
- echo '<td class="diff-code"><span class="diff-marker">' .
- $char . '</span>' . htmlspecialchars( $line['l'] ) . '</td>';
- echo '</tr>';
}
Delta 26 lines added, 34 lines removed, 8-line decrease