Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.22.0@fc2c6ab4d5fa5d644d8617089f012f3bb84b8703">
<files psalm-version="4.23.0@f1fe6ff483bf325c803df9f510d09a03fd796f88">
<file src="src/Classes/Config.php">
<UndefinedVariable occurrences="1">
<code>$configuration</code>
</UndefinedVariable>
</file>
<file src="src/Classes/DependencyBuilder.php">
<FalsableReturnStatement occurrences="1">
<code>false</code>
</FalsableReturnStatement>
<PossiblyNullArgument occurrences="1">
<code>$module</code>
</PossiblyNullArgument>
</file>
<file src="src/Classes/IndexController.php">
<ForbiddenCode occurrences="1">
<code>shell_exec($command)</code>
</ForbiddenCode>
<PossiblyNullReference occurrences="4">
<code>getChangeLogMd</code>
<code>getInstallationMd</code>
Expand Down
43 changes: 43 additions & 0 deletions src/Classes/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br>
🔀 Branch: <strong>' . $gitBranch . '</strong><br>
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();
Expand Down Expand Up @@ -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;
}
}