From e18252b49168fec4adb5ac57b9ae4a451c332d4d Mon Sep 17 00:00:00 2001 From: Akurosia Kamo Date: Wed, 27 May 2026 14:41:35 +0200 Subject: [PATCH] add commit and push commands from web --- admin.php | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/admin.php b/admin.php index 89de681..ccf9856 100644 --- a/admin.php +++ b/admin.php @@ -63,6 +63,11 @@ function branch_from_remote(string $remoteBranch): string { 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; @@ -78,6 +83,23 @@ if ($allowed && $_SERVER['REQUEST_METHOD'] === 'POST') { } 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(); @@ -121,7 +143,7 @@ if ($allowed) { $status = git_output(['status', '-sb']); $branches = git_local_branches(); $remoteBranches = git_remote_branches(); - $lastCommit = git_output(['log', '-1', '--pretty=%h %s (%cr)']); + $lastCommit = git_last_commit(); } ?> @@ -199,6 +221,7 @@ if ($allowed) { +
@@ -225,6 +248,16 @@ if ($allowed) {
+ +
+ + +
+ + +
+ +