1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-08-04 21:42:57 +02:00

Don't ignore errors from checkout source code (#1584)

Don't check out code for builtin services.
This commit is contained in:
Janos Dobronszki
2020-04-28 10:51:39 +02:00
committed by GitHub
parent 8148e0a0f8
commit b875868a39
2 changed files with 22 additions and 8 deletions

View File

@ -1,6 +1,7 @@
package git
import (
"errors"
"fmt"
"os"
"os/exec"
@ -105,7 +106,7 @@ type binaryGitter struct {
}
func (g binaryGitter) Clone(repo string) error {
fold := filepath.Join(g.folder, dirifyRepo(repo))
fold := filepath.Join(g.folder, dirifyRepo(repo), ".git")
exists, err := pathExists(fold)
if err != nil {
return err
@ -113,6 +114,7 @@ func (g binaryGitter) Clone(repo string) error {
if exists {
return nil
}
fold = filepath.Join(g.folder, dirifyRepo(repo))
cmd := exec.Command("git", "clone", repo, ".")
err = os.MkdirAll(fold, 0777)
@ -130,9 +132,9 @@ func (g binaryGitter) Clone(repo string) error {
func (g binaryGitter) FetchAll(repo string) error {
cmd := exec.Command("git", "fetch", "--all")
cmd.Dir = filepath.Join(g.folder, dirifyRepo(repo))
_, err := cmd.Output()
outp, err := cmd.CombinedOutput()
if err != nil {
return err
return errors.New(string(outp))
}
return err
}
@ -143,9 +145,9 @@ func (g binaryGitter) Checkout(repo, branchOrCommit string) error {
}
cmd := exec.Command("git", "checkout", "-f", branchOrCommit)
cmd.Dir = filepath.Join(g.folder, dirifyRepo(repo))
_, err := cmd.Output()
outp, err := cmd.CombinedOutput()
if err != nil {
return err
return errors.New(string(outp))
}
return nil
}