Fix: UpdateCard + CheckUpdates bevorzugen git-Tag über veraltete Version-Datei
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 <noreply@anthropic.com>main v1.1.349
parent
cae269fae1
commit
dbd7848f68
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue