&1'; exec($cmd, $lines, $code); return ['code' => $code, 'output' => trim(implode("\n", $lines))]; } function git_output(array $args): string { return git_run($args)['output']; } function git_local_branches(): array { $out = git_output(['branch', '--list', '--no-color']); $branches = array_values(array_filter(array_map(function ($line) { return trim(ltrim(trim($line), '*')); }, explode("\n", $out)), fn($v) => $v !== '')); sort($branches, SORT_NATURAL | SORT_FLAG_CASE); return $branches; } function git_remote_branches(): array { $out = git_output(['branch', '-r', '--no-color']); $branches = array_values(array_filter(array_map('trim', explode("\n", $out)), function ($branch) { return $branch !== '' && !str_contains($branch, ' -> ') && !str_ends_with($branch, '/HEAD'); })); sort($branches, SORT_NATURAL | SORT_FLAG_CASE); return $branches; } function branch_from_remote(string $remoteBranch): string { $parts = explode('/', $remoteBranch, 2); return $parts[1] ?? $remoteBranch; } function git_last_commit(): string { $out = git_output(['log', '-1', '--oneline', '--decorate=short']); return $out !== '' ? $out : '(unknown)'; } $message = null; $result = null; if ($allowed && $_SERVER['REQUEST_METHOD'] === 'POST') { if (!hash_equals($csrf, $_POST['csrf'] ?? '')) { http_response_code(400); $message = 'Invalid CSRF token.'; } else { $action = $_POST['action'] ?? ''; if ($action === 'fetch') { $result = git_run(['fetch', '--prune']); $message = 'git fetch --prune'; } elseif ($action === 'pull') { $result = git_run(['pull', '--ff-only']); $message = 'git pull --ff-only'; } elseif ($action === 'push') { $result = git_run(['push']); $message = 'git push'; } elseif ($action === 'commit') { $commitMessage = trim((string)($_POST['message'] ?? '')); if ($commitMessage === '') { $result = ['code' => 1, 'output' => 'Commit message is required.']; } else { $add = git_run(['add', '-A']); if ($add['code'] !== 0) { $result = $add; $message = 'git add -A'; } else { $result = git_run(['commit', '-m', $commitMessage]); $message = 'git commit'; } } } elseif ($action === 'switch') { $ref = trim((string)($_POST['branch'] ?? '')); $localBranches = git_local_branches(); $remoteBranches = git_remote_branches(); if (str_starts_with($ref, 'local:')) { $branch = substr($ref, 6); if (!in_array($branch, $localBranches, true)) { $result = ['code' => 1, 'output' => 'Unknown local branch: ' . $branch]; } else { $result = git_run(['switch', $branch]); $message = 'git switch ' . $branch; } } elseif (str_starts_with($ref, 'remote:')) { $remoteBranch = substr($ref, 7); if (!in_array($remoteBranch, $remoteBranches, true)) { $result = ['code' => 1, 'output' => 'Unknown remote branch: ' . $remoteBranch]; } else { $branch = branch_from_remote($remoteBranch); if (in_array($branch, $localBranches, true)) { $result = git_run(['switch', $branch]); $message = 'git switch ' . $branch; } else { $result = git_run(['switch', '--track', $remoteBranch]); $message = 'git switch --track ' . $remoteBranch; } } } else { $result = ['code' => 1, 'output' => 'Unknown branch selection.']; } } } } $currentBranch = ''; $status = ''; $branches = []; $remoteBranches = []; $lastCommit = ''; if ($allowed) { $currentBranch = git_output(['rev-parse', '--abbrev-ref', 'HEAD']); $status = git_output(['status', '-sb']); $branches = git_local_branches(); $remoteBranches = git_remote_branches(); $lastCommit = git_last_commit(); } ?> Admin · FFLogs Report Viewer
User nicht verfügbar

Ich konnte deine FFLogs User-ID nicht laden.

Kein Zugriff

Deine FFLogs User-ID ist . Füge diese ID in deiner .env zu ADMIN_USER_IDS hinzu, um diese Seite freizuschalten.

Git Admin
Branch:
Last commit:
Aktionen
Status
· Exit