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 }