From 6369db2e8e5437c082e0c40bdb3175a654847e44 Mon Sep 17 00:00:00 2001 From: jessetang <1430482733@qq.com> Date: Thu, 16 Mar 2023 11:33:22 +0800 Subject: [PATCH] fix(cmd/kratos/internal/base/repo.go): missing error (#2734) * fix(cmd/kratos/internal/base): missing error * fix --- cmd/kratos/internal/base/path.go | 14 ++++++-------- cmd/kratos/internal/base/repo.go | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/cmd/kratos/internal/base/path.go b/cmd/kratos/internal/base/path.go index f0a505cec..7456ba67a 100644 --- a/cmd/kratos/internal/base/path.go +++ b/cmd/kratos/internal/base/path.go @@ -37,7 +37,6 @@ func kratosHomeWithDir(dir string) string { } func copyFile(src, dst string, replaces []string) error { - var err error srcinfo, err := os.Stat(src) if err != nil { return err @@ -58,19 +57,18 @@ func copyFile(src, dst string, replaces []string) error { } func copyDir(src, dst string, replaces, ignores []string) error { - var err error - var fds []os.DirEntry - var srcinfo os.FileInfo - - if srcinfo, err = os.Stat(src); err != nil { + srcinfo, err := os.Stat(src) + if err != nil { return err } - if err = os.MkdirAll(dst, srcinfo.Mode()); err != nil { + err = os.MkdirAll(dst, srcinfo.Mode()) + if err != nil { return err } - if fds, err = os.ReadDir(src); err != nil { + fds, err := os.ReadDir(src) + if err != nil { return err } for _, fd := range fds { diff --git a/cmd/kratos/internal/base/repo.go b/cmd/kratos/internal/base/repo.go index bdcb3f010..4ad241c89 100644 --- a/cmd/kratos/internal/base/repo.go +++ b/cmd/kratos/internal/base/repo.go @@ -68,7 +68,7 @@ func (r *Repo) Pull(ctx context.Context) error { cmd.Dir = r.Path() _, err := cmd.CombinedOutput() if err != nil { - return nil + return err } cmd = exec.CommandContext(ctx, "git", "pull") cmd.Dir = r.Path()