chore(*): update command error type

Signed-off-by: storyicon <yuanchao@bilibili.com>
This commit is contained in:
storyicon 2021-07-22 20:41:06 +08:00
parent a4d4c459ba
commit 1c73b92f0f
No known key found for this signature in database
GPG key ID: 245915D985F966CF
5 changed files with 9 additions and 9 deletions

View file

@ -72,7 +72,7 @@ func (m *BasicActionManager) ExecutePostShell(ctx context.Context, config config
if err != nil {
return &ErrPostShell{
Path: config.Path(),
ErrCommandExec: err,
ErrCommandExec: err.(*command.ErrCommandExec),
}
}
return nil

View file

@ -104,7 +104,7 @@ func (b *BasicCompiler) Compile(ctx context.Context, protoFilePath string) error
b.Logger, b.dir, b.protocPath, arguments, nil)
if err != nil {
return &ErrCompile{
ErrCommandExec: err,
ErrCommandExec: err.(*command.ErrCommandExec),
}
}
return nil

View file

@ -34,13 +34,13 @@ func GetGitLatestCommitId(ctx context.Context, log logger.Logger, repo string) (
}, nil)
if err != nil {
return "", &ErrGitList{
ErrCommandExec: err,
ErrCommandExec: err.(*command.ErrCommandExec),
}
}
f := strings.Fields(string(data))
if len(f) != 2 {
return "", &ErrGitList{
ErrCommandExec: err,
ErrCommandExec: err.(*command.ErrCommandExec),
}
}
return f[0], nil
@ -53,7 +53,7 @@ func ListGitCommitIds(ctx context.Context, log logger.Logger, repo string) ([]st
}, nil)
if err != nil {
return nil, &ErrGitList{
ErrCommandExec: err,
ErrCommandExec: err.(*command.ErrCommandExec),
}
}
var commitIds []string
@ -74,7 +74,7 @@ func ListGitTags(ctx context.Context, log logger.Logger, repo string) ([]string,
}, nil)
if err != nil {
return nil, &ErrGitList{
ErrCommandExec: err,
ErrCommandExec: err.(*command.ErrCommandExec),
}
}
var tags []string

View file

@ -71,7 +71,7 @@ func InstallPluginUsingGo(ctx context.Context,
}, []string{"GOBIN=" + dir, "GO111MODULE=on"})
if err2 != nil {
return "", &ErrGoInstall{
ErrCommandExec: err2,
ErrCommandExec: err2.(*command.ErrCommandExec),
}
}
return local, nil
@ -114,7 +114,7 @@ func ListGoPackageVersions(ctx context.Context, log logger.Logger, path string)
})
if err != nil {
return nil, &ErrGoList{
ErrCommandExec: err,
ErrCommandExec: err.(*command.ErrCommandExec),
}
}
var module Module

View file

@ -29,7 +29,7 @@ import (
// Execute is used to execute commands, return stdout and execute errors
func Execute(ctx context.Context,
log logger.Logger,
dir string, name string, arguments []string, env []string) ([]byte, *ErrCommandExec) {
dir string, name string, arguments []string, env []string) ([]byte, error) {
cmd := exec.CommandContext(ctx, name, arguments...)
cmd.Env = append(os.Environ(), env...)
cmd.Dir = dir