show verbose output from go mod tidy for debugging
This commit is contained in:
parent
ea14fc629d
commit
063e4e57c8
|
@ -41,7 +41,7 @@ func redoGoMod(repo *gitpb.Repo) error {
|
||||||
log.Warn("go mod init failed", err)
|
log.Warn("go mod init failed", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := repo.StrictRun([]string{"go", "mod", "tidy", "-go=1.21"}); err != nil {
|
if err := runVerbose(repo.FullPath, []string{"go", "mod", "tidy", "-go=1.21"}); err != nil {
|
||||||
log.Warn("go mod tidy failed", err)
|
log.Warn("go mod tidy failed", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
38
run.go
38
run.go
|
@ -68,3 +68,41 @@ func runStrict(wd string, cmd []string) {
|
||||||
log.Info(i, line)
|
log.Info(i, line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func runVerbose(wd string, cmd []string) error {
|
||||||
|
var err error
|
||||||
|
log.DaemonMode(true)
|
||||||
|
defer log.DaemonMode(false)
|
||||||
|
if wd != "" {
|
||||||
|
if err = os.Chdir(wd); err != nil {
|
||||||
|
return fmt.Errorf("cd %s failed %v", wd, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Info(wd, "running:", wd, cmd)
|
||||||
|
// result := shell.Run(cmd)
|
||||||
|
result := shell.Run(cmd)
|
||||||
|
if result.Error != nil {
|
||||||
|
log.Info("cmd failed", wd, cmd, err)
|
||||||
|
for _, line := range result.Stdout {
|
||||||
|
log.Info(line)
|
||||||
|
}
|
||||||
|
for i, line := range result.Stderr {
|
||||||
|
log.Info("STDERR:", i, line)
|
||||||
|
}
|
||||||
|
return result.Error
|
||||||
|
}
|
||||||
|
if result.Exit != 0 {
|
||||||
|
log.Info("cmd failed", wd, cmd, err)
|
||||||
|
for _, line := range result.Stdout {
|
||||||
|
log.Info(line)
|
||||||
|
}
|
||||||
|
for i, line := range result.Stderr {
|
||||||
|
log.Info("STDERR:", i, line)
|
||||||
|
}
|
||||||
|
return fmt.Errorf("cmd failed with %d", result.Exit)
|
||||||
|
}
|
||||||
|
for _, line := range result.Stdout {
|
||||||
|
log.Info(line)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue