feat: 为QQ机器人添加Git仓库管理接口

新增了Git仓库管理相关功能:
1. 在router中添加/git路由组
2. 新增代码拉取、构建和重启的HTTP接口
3. 将Git拉取逻辑抽取到util包中
4. 支持通过HTTP请求触发代码拉取、构建和重启操作
5. 扩展CORS配置,允许git.lxtend.com域名访问
This commit is contained in:
lixiangwuxian
2025-03-09 01:32:49 +08:00
parent 8049ec7946
commit cfd20cbefe
3 changed files with 52 additions and 13 deletions

22
util/automatic.go Normal file
View File

@@ -0,0 +1,22 @@
package util
import (
"errors"
"os"
"os/exec"
)
func GitPull() error {
workDir, err := os.Getwd()
if err != nil {
return err
}
cmd := exec.Command("git", "pull")
cmd.Dir = workDir
output, err := cmd.CombinedOutput()
if err != nil {
return errors.New(string(output) + err.Error())
}
return nil
}