mirror of
https://gitee.com/goploy/goploy.git
synced 2024-12-02 04:07:33 +08:00
F index out of range
This commit is contained in:
parent
70758660ae
commit
e3e87a98c8
@ -478,7 +478,7 @@ func (Deploy) Rebuild(gp *server.Goploy) server.Response {
|
||||
scriptName := fmt.Sprintf("goploy-after-deploy-p%d-s%d.%s", project.ID, projectServer.ServerID, pkg.GetScriptExt(project.AfterDeployScriptMode))
|
||||
scriptContent := project.ReplaceVars(project.AfterDeployScript)
|
||||
scriptContent = projectServer.ReplaceVars(scriptContent)
|
||||
ioutil.WriteFile(path.Join(config.GetProjectPath(project.ID), scriptName), []byte(project.ReplaceVars(project.AfterDeployScript)), 0755)
|
||||
os.WriteFile(path.Join(config.GetProjectPath(project.ID), scriptName), []byte(project.ReplaceVars(project.AfterDeployScript)), 0755)
|
||||
afterDeployScriptPath := path.Join(project.Path, scriptName)
|
||||
afterDeployCommands = append(afterDeployCommands, cmdEntity.Script(project.AfterDeployScriptMode, afterDeployScriptPath))
|
||||
afterDeployCommands = append(afterDeployCommands, cmdEntity.Remove(afterDeployScriptPath))
|
||||
|
@ -567,7 +567,7 @@ func (Project) UploadFile(gp *server.Goploy) server.Response {
|
||||
return response.JSON{Code: response.Error, Message: err.Error()}
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(filePath, fileBytes, 0755); err != nil {
|
||||
if err := os.WriteFile(filePath, fileBytes, 0755); err != nil {
|
||||
return response.JSON{Code: response.Error, Message: err.Error()}
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ func main() {
|
||||
println(err.Error())
|
||||
}
|
||||
pid := strconv.Itoa(os.Getpid())
|
||||
_ = ioutil.WriteFile(config.GetPidFile(), []byte(pid), 0755)
|
||||
_ = os.WriteFile(config.GetPidFile(), []byte(pid), 0755)
|
||||
println("Start at " + time.Now().String())
|
||||
println("goploy -h for more help")
|
||||
println("Current pid: " + pid)
|
||||
|
@ -165,7 +165,23 @@ func (gsync Gsync) Exec() {
|
||||
return
|
||||
}
|
||||
|
||||
commitList, _ := r.CommitLog(gsync.Project.ID, 1)
|
||||
commitList, err := r.CommitLog(gsync.Project.ID, 1)
|
||||
if err != nil {
|
||||
log.Errorf(projectLogFormat, gsync.Project.ID, err)
|
||||
ws.GetHub().Data <- &ws.Data{
|
||||
Type: ws.TypeProject,
|
||||
Message: deployMessage{ProjectID: gsync.Project.ID, ProjectName: gsync.Project.Name, State: DeployFail, Message: err.Error()},
|
||||
}
|
||||
_ = gsync.Project.DeployFail()
|
||||
publishTraceModel.Detail = err.Error()
|
||||
publishTraceModel.State = model.Fail
|
||||
if _, err := publishTraceModel.AddRow(); err != nil {
|
||||
log.Errorf(projectLogFormat, gsync.Project.ID, err)
|
||||
}
|
||||
gsync.notify(model.ProjectFail, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
gsync.CommitInfo = commitList[0]
|
||||
if gsync.Branch != "" {
|
||||
gsync.CommitInfo.Branch = gsync.Branch
|
||||
@ -276,7 +292,7 @@ func (gsync Gsync) runAfterPullScript() (string, error) {
|
||||
scriptMode = project.AfterPullScriptMode
|
||||
}
|
||||
scriptText := project.ReplaceVars(commitInfo.ReplaceVars(project.AfterPullScript))
|
||||
_ = ioutil.WriteFile(scriptFullName, []byte(scriptText), 0755)
|
||||
_ = os.WriteFile(scriptFullName, []byte(scriptText), 0755)
|
||||
var commandOptions []string
|
||||
if project.AfterPullScriptMode == "cmd" {
|
||||
commandOptions = append(commandOptions, "/C")
|
||||
@ -311,7 +327,7 @@ func (gsync Gsync) remoteSync(msgChIn chan<- syncMessage) {
|
||||
if len(project.AfterDeployScript) != 0 {
|
||||
scriptContent := project.ReplaceVars(project.AfterDeployScript)
|
||||
scriptContent = projectServer.ReplaceVars(scriptContent)
|
||||
_ = ioutil.WriteFile(path.Join(config.GetProjectPath(project.ID), scriptName), []byte(scriptContent), 0755)
|
||||
_ = os.WriteFile(path.Join(config.GetProjectPath(project.ID), scriptName), []byte(scriptContent), 0755)
|
||||
}
|
||||
|
||||
transmitterEntity := transmitter.New(project, projectServer)
|
||||
|
@ -7,6 +7,7 @@ package config
|
||||
import (
|
||||
"github.com/pelletier/go-toml/v2"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -107,7 +108,7 @@ func Write(cfg Config) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(GetConfigFile(), yamlData, 0644)
|
||||
err = os.WriteFile(GetConfigFile(), yamlData, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ func (GitRepo) CanRollback() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Ping -
|
||||
func (GitRepo) Ping(url string) error {
|
||||
git := pkg.GIT{}
|
||||
if err := git.LsRemote("-h", url); err != nil {
|
||||
@ -32,7 +31,6 @@ func (GitRepo) Ping(url string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Create -
|
||||
func (GitRepo) Create(projectID int64) error {
|
||||
srcPath := config.GetProjectPath(projectID)
|
||||
if _, err := os.Stat(srcPath); err == nil {
|
||||
@ -79,13 +77,13 @@ func (gitRepo GitRepo) Follow(project model.Project, target string) error {
|
||||
log.Trace("projectID:" + strconv.FormatInt(project.ID, 10) + " git add .")
|
||||
if err := git.Add("."); err != nil {
|
||||
log.Error(err.Error() + ", detail: " + git.Err.String())
|
||||
return errors.New(git.Err.String())
|
||||
return err
|
||||
}
|
||||
|
||||
log.Trace("projectID:" + strconv.FormatInt(project.ID, 10) + " git reset --hard")
|
||||
if err := git.Reset("--hard"); err != nil {
|
||||
log.Error(err.Error() + ", detail: " + git.Err.String())
|
||||
return errors.New(git.Err.String())
|
||||
return err
|
||||
}
|
||||
|
||||
// the length of commit id is 40
|
||||
@ -93,14 +91,14 @@ func (gitRepo GitRepo) Follow(project model.Project, target string) error {
|
||||
log.Trace("projectID:" + strconv.FormatInt(project.ID, 10) + " git fetch")
|
||||
if err := git.Fetch(); err != nil {
|
||||
log.Error(err.Error() + ", detail: " + git.Err.String())
|
||||
return errors.New(git.Err.String())
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
log.Trace("projectID:" + strconv.FormatInt(project.ID, 10) + " git checkout -B goploy " + target)
|
||||
if err := git.Checkout("-B", "goploy", target); err != nil {
|
||||
log.Error(err.Error() + ", detail: " + git.Err.String())
|
||||
return errors.New(git.Err.String())
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -108,7 +106,7 @@ func (gitRepo GitRepo) Follow(project model.Project, target string) error {
|
||||
func (GitRepo) RemoteBranchList(url string) ([]string, error) {
|
||||
git := pkg.GIT{}
|
||||
if err := git.LsRemote("-h", url); err != nil {
|
||||
return []string{}, errors.New(git.Err.String())
|
||||
return []string{}, err
|
||||
}
|
||||
|
||||
var list []string
|
||||
@ -131,7 +129,7 @@ func (GitRepo) BranchList(projectID int64) ([]string, error) {
|
||||
}
|
||||
|
||||
if err := git.Branch("-r", "--sort=-committerdate"); err != nil {
|
||||
return []string{}, errors.New(err.Error() + " detail: " + git.Err.String())
|
||||
return []string{}, err
|
||||
}
|
||||
|
||||
rawBranchList := strings.Split(git.Output.String(), "\n")
|
||||
@ -150,7 +148,7 @@ func (GitRepo) CommitLog(projectID int64, rows int) ([]CommitInfo, error) {
|
||||
git := pkg.GIT{Dir: config.GetProjectPath(projectID)}
|
||||
|
||||
if err := git.Log("--stat", "--pretty=format:`start`%H`%an`%at`%s`%d`", "-n", strconv.Itoa(rows)); err != nil {
|
||||
return []CommitInfo{}, errors.New(git.Err.String())
|
||||
return []CommitInfo{}, err
|
||||
}
|
||||
|
||||
list := parseGITLog(git.Output.String())
|
||||
@ -161,7 +159,7 @@ func (GitRepo) BranchLog(projectID int64, branch string, rows int) ([]CommitInfo
|
||||
git := pkg.GIT{Dir: config.GetProjectPath(projectID)}
|
||||
|
||||
if err := git.Log(branch, "--stat", "--pretty=format:`start`%H`%an`%at`%s`%d`", "-n", strconv.Itoa(rows)); err != nil {
|
||||
return []CommitInfo{}, errors.New(git.Err.String())
|
||||
return []CommitInfo{}, err
|
||||
}
|
||||
|
||||
list := parseGITLog(git.Output.String())
|
||||
@ -171,19 +169,19 @@ func (GitRepo) BranchLog(projectID int64, branch string, rows int) ([]CommitInfo
|
||||
func (GitRepo) TagLog(projectID int64, rows int) ([]CommitInfo, error) {
|
||||
git := pkg.GIT{Dir: config.GetProjectPath(projectID)}
|
||||
if err := git.Add("."); err != nil {
|
||||
return []CommitInfo{}, errors.New(git.Err.String())
|
||||
return []CommitInfo{}, err
|
||||
}
|
||||
|
||||
if err := git.Reset("--hard"); err != nil {
|
||||
return []CommitInfo{}, errors.New(git.Err.String())
|
||||
return []CommitInfo{}, err
|
||||
}
|
||||
|
||||
if err := git.Pull(); err != nil {
|
||||
return []CommitInfo{}, errors.New(git.Err.String())
|
||||
return []CommitInfo{}, err
|
||||
}
|
||||
|
||||
if err := git.Log("--tags", "-n", strconv.Itoa(rows), "--no-walk", "--stat", "--pretty=format:`start`%H`%an`%at`%s`%d`"); err != nil {
|
||||
return []CommitInfo{}, errors.New(git.Err.String())
|
||||
return []CommitInfo{}, err
|
||||
}
|
||||
|
||||
list := parseGITLog(git.Output.String())
|
||||
|
Loading…
Reference in New Issue
Block a user