diff --git a/psalm-baseline.xml b/psalm-baseline.xml index bdace0a4..4cbddfa9 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,19 +1,14 @@ - + $configuration - - - false - - - $module - - + + shell_exec($command) + getChangeLogMd getInstallationMd diff --git a/src/Classes/IndexController.php b/src/Classes/IndexController.php index f78622e0..a6bec6b8 100644 --- a/src/Classes/IndexController.php +++ b/src/Classes/IndexController.php @@ -137,6 +137,19 @@ public function invokeSelfUpdate() return $accessRedirect; } + $gitBranch = $this->getCurrentGitBranch(App::getRoot() . '/.git'); + + if ($gitBranch) { + Notification::pushFlashMessage([ + 'text' => + 'Der MMLC wurde über Git installiert.
+ 🔀 Branch: ' . $gitBranch . '
+ Bitte führe die Aktualisierung des MMLC über Git durch. Beachte, dass ein Update über den MMLC + möglicherweise zu Fehlern führen kann.', + 'type' => 'warning' + ]); + } + // Nächste mögliche MMLC Version ermittlen $latest = Config::getSelfUpdate() == 'latest'; $installedMmlcVersionString = App::getMmlcVersion(); @@ -737,4 +750,34 @@ private function addModuleNotFoundNotification($archiveName, $version = '') 'type' => 'error' ]); } + + private function getCurrentGitBranch(string $gitPath): ?string + { + if (!is_dir($gitPath)) { + return null; + } + + $os = strtoupper(substr(PHP_OS, 0, 3)); + $command = ''; + + switch ($os) { + case 'WIN': + $command = 'cd /d "' . $gitPath . '" & git symbolic-ref --short HEAD 2>NUL'; + break; + case 'LIN': + case 'DAR': + $command = 'cd "' . $gitPath . '" && git symbolic-ref --short HEAD 2>/dev/null'; + break; + default: + return 'unkown branch'; + } + + $output = trim('' . shell_exec($command)); + + if (empty($output)) { + return null; + } + + return $output; + } }