no message
This commit is contained in:
parent
fe55a54160
commit
292a5e53ab
@ -5,6 +5,40 @@ use App\Models\Article as ModelArticle;
|
||||
|
||||
class Git extends Base {
|
||||
|
||||
public function LastTime($aParam)
|
||||
{
|
||||
$iId = $aParam['aArg'][1];
|
||||
|
||||
$aArticle = ModelArticle::find($iId);
|
||||
|
||||
$sProjectPath = env("BASE_DIR") . "github/" . $aArticle->user_name . "-" . $aArticle->project_name;
|
||||
|
||||
// 进入指定目录
|
||||
if (!chdir($sProjectPath)) {
|
||||
throw new \Exception("无法进入目录" . $sProjectPath);
|
||||
}
|
||||
|
||||
// 获取远程更新
|
||||
$fetchOutput = $this->runCommand('git fetch origin');
|
||||
if (empty($fetchOutput)) {
|
||||
throw new \Exception("获取远程更新失败,输出为空。");
|
||||
}
|
||||
|
||||
// 获取最后提交的时间
|
||||
$lastCommitTime = $this->runCommand('git log -1 --format=%cd origin/main');
|
||||
|
||||
// 检查是否获取到时间
|
||||
if (empty($lastCommitTime)) {
|
||||
throw new \Exception("无法获取最后提交时间,可能是分支不存在或没有提交。");
|
||||
}
|
||||
|
||||
// 发送最后更新时间到 Telegram
|
||||
$this->oTGHttp->sendToTG("最后更新时间: " . trim($lastCommitTime));
|
||||
|
||||
$this->oHttp::response(200, 'ok');
|
||||
}
|
||||
|
||||
// 没用
|
||||
public function AddSshHostGithub()
|
||||
{
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user