From 5b7a5a5aca08415ce4c2998d0659014ae7768625 Mon Sep 17 00:00:00 2001 From: lixiangwuxian Date: Mon, 5 May 2025 02:26:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9C=A8=20PullCodeHandler=20=E5=92=8C?= =?UTF-8?q?=20BuildBotHandler=20=E4=B8=AD=E6=B7=BB=E5=8A=A0=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95=EF=BC=8C=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86=E7=9A=84=E5=8F=AF?= =?UTF-8?q?=E8=BF=BD=E6=BA=AF=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/restart/restart.go | 2 ++ util/automatic.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/handler/restart/restart.go b/handler/restart/restart.go index d85761f..9746a82 100644 --- a/handler/restart/restart.go +++ b/handler/restart/restart.go @@ -181,6 +181,7 @@ func PullCodeHandler(c *gin.Context) { err := util.GitPull() log.Println("拉取代码...") if err != nil { + log.Println(err) c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } @@ -197,6 +198,7 @@ func BuildBotHandler(c *gin.Context) { err := buildBot() log.Println("构建程序...") if err != nil { + log.Println(err) c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } diff --git a/util/automatic.go b/util/automatic.go index f227533..0a4b6ba 100644 --- a/util/automatic.go +++ b/util/automatic.go @@ -58,5 +58,13 @@ func GitPull() error { return errors.New(string(forceResetOutput) + err.Error()) } + // 拉取最新代码 + pullCmd := exec.Command("git", "pull") + pullCmd.Dir = workDir + pullOutput, err := pullCmd.CombinedOutput() + if err != nil { + return errors.New(string(pullOutput) + err.Error()) + } + return nil }