From dbd7848f684593aecf1bec974e91c1ec50e1e023 Mon Sep 17 00:00:00 2001 From: boban Date: Sun, 26 Apr 2026 22:03:09 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20UpdateCard=20+=20CheckUpdates=20bevorzug?= =?UTF-8?q?en=20git-Tag=20=C3=BCber=20veraltete=20Version-Datei?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dev-Server zeigte v1.0.137 weil /var/lib/mailwolt/version nie aktualisiert wurde. git describe --tags liefert immer die korrekte aktuelle Version. Co-Authored-By: Claude Sonnet 4.6 --- app/Console/Commands/CheckUpdates.php | 24 +++++++++++----------- app/Livewire/Ui/System/UpdateCard.php | 29 ++++++++++++--------------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/app/Console/Commands/CheckUpdates.php b/app/Console/Commands/CheckUpdates.php index b87d756..9e0571e 100644 --- a/app/Console/Commands/CheckUpdates.php +++ b/app/Console/Commands/CheckUpdates.php @@ -79,21 +79,21 @@ class CheckUpdates extends Command private function readInstalledVersionNorm(): ?string { - // Version-Datei ist autoritativ — immer zuerst prüfen - $paths = [ - '/var/lib/mailwolt/version', - base_path('VERSION'), - ]; - foreach ($paths as $p) { + $fileVer = null; + foreach (['/var/lib/mailwolt/version', base_path('VERSION')] as $p) { $raw = @trim(@file_get_contents($p) ?: ''); - if ($raw !== '') return $this->normalizeVersion($raw); + if ($raw !== '') { $fileVer = $this->normalizeVersion($raw); break; } } - $raw = $this->readInstalledVersionRaw(); - if ($raw) return $this->normalizeVersion($raw); - // Nur wenn keine Version-Datei existiert (z.B. frische Dev-Umgebung) - $tag = @trim((string) shell_exec('git -C ' . escapeshellarg(base_path()) . ' describe --tags --abbrev=0 2>/dev/null')); - return $this->normalizeVersion($tag); + // git-Tag bevorzugen wenn neuer (Dev-Server hat oft veraltete Versionsdatei) + $out = []; + @exec('git -C ' . escapeshellarg(base_path()) . ' describe --tags --abbrev=0 2>/dev/null', $out); + $gitVer = $this->normalizeVersion(trim($out[0] ?? '')); + + if ($gitVer && (!$fileVer || version_compare($gitVer, $fileVer, '>'))) { + return $gitVer; + } + return $fileVer ?: $this->normalizeVersion($this->readInstalledVersionRaw() ?? ''); } private function readInstalledVersionRaw(): ?string diff --git a/app/Livewire/Ui/System/UpdateCard.php b/app/Livewire/Ui/System/UpdateCard.php index 8dd7360..0ba9b0c 100644 --- a/app/Livewire/Ui/System/UpdateCard.php +++ b/app/Livewire/Ui/System/UpdateCard.php @@ -335,27 +335,24 @@ class UpdateCard extends Component protected function readCurrentVersion(): ?string { // 1) normierte Version vom Wrapper - $v = @trim(@file_get_contents(self::VERSION_FILE) ?: ''); - if ($v !== '') return $v; + $fileVer = $this->normalizeVersion(@trim(@file_get_contents(self::VERSION_FILE) ?: '')); - // 2) raw -> normieren + // 2) git-Tag (bevorzugt wenn neuer als Datei – z.B. auf Dev-Server) + $out = []; + @exec('git -C ' . escapeshellarg(base_path()) . ' describe --tags --abbrev=0 2>/dev/null', $out); + $gitVer = $this->normalizeVersion(trim($out[0] ?? '')); + + if ($gitVer && (!$fileVer || version_compare($gitVer, $fileVer, '>'))) { + return $gitVer; + } + if ($fileVer) return $fileVer; + + // 3) raw -> normieren $raw = @trim(@file_get_contents(self::VERSION_FILE_RAW) ?: ''); if ($raw !== '') return $this->normalizeVersion($raw); - // 3) build.info - $build = @file_get_contents(self::BUILD_INFO); - if ($build) { - foreach (preg_split('/\R+/', $build) as $line) { - if (str_starts_with($line, 'version=')) { - $v = $this->normalizeVersion(trim(substr($line, 8))); - if ($v) return $v; - } - } - } - // 4) Fallback auf config(app.version) - $v = $this->normalizeVersion(config('app.version') ?: ''); - return $v ?: null; + return $this->normalizeVersion(config('app.version') ?: '') ?: null; } protected function normalizeVersion(?string $v): ?string