自动提交
This commit is contained in:
44
test_git_add_commit.php
Normal file
44
test_git_add_commit.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
// 测试Git添加和提交操作
|
||||
$apiUrl = 'http://localhost:8080/index.php';
|
||||
|
||||
// 测试Git添加
|
||||
echo "测试Git添加操作\n";
|
||||
$ch = curl_init($apiUrl);
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => http_build_query(['action' => 'git_operation', 'operation' => 'add']),
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => ['Content-Type: application/x-www-form-urlencoded']
|
||||
]);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if ($response) {
|
||||
$result = json_decode($response, true);
|
||||
echo "Git添加结果:\n";
|
||||
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n\n";
|
||||
}
|
||||
|
||||
// 测试Git提交
|
||||
echo "测试Git提交操作\n";
|
||||
$ch = curl_init($apiUrl);
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => http_build_query([
|
||||
'action' => 'git_operation',
|
||||
'operation' => 'commit',
|
||||
'message' => '测试提交:修复Git仓库路径问题'
|
||||
]),
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => ['Content-Type: application/x-www-form-urlencoded']
|
||||
]);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if ($response) {
|
||||
$result = json_decode($response, true);
|
||||
echo "Git提交结果:\n";
|
||||
echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n\n";
|
||||
}
|
||||
|
||||
echo "Git操作测试完成!\n";
|
||||
?>
|
||||
Reference in New Issue
Block a user