go modules cleanup and remove wrong self import to v1 (#1658)

* Runtime local git, simply go-git code
* go modules cleanup and remove wrong self import to v1
* pin mergo v0.3.8 to avoid panics

Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Máximo Cuadros
2020-05-29 13:32:11 +02:00
committed by GitHub
parent 8660370dc9
commit 0d88650511
5 changed files with 41 additions and 116 deletions

View File

@@ -74,27 +74,18 @@ func (g libGitter) Checkout(repo, branchOrCommit string) error {
if err != nil {
return err
}
isCommit := func(s string) bool {
return strings.ContainsAny(s, "0123456789") && len(s) == 40
}
if isCommit(branchOrCommit) {
err = worktree.Checkout(&git.CheckoutOptions{
if plumbing.IsHash(branchOrCommit) {
return worktree.Checkout(&git.CheckoutOptions{
Hash: plumbing.NewHash(branchOrCommit),
Force: true,
})
if err != nil {
return err
}
} else {
err = worktree.Checkout(&git.CheckoutOptions{
Branch: plumbing.NewBranchReferenceName(branchOrCommit),
Force: true,
})
if err != nil {
return err
}
}
return nil
return worktree.Checkout(&git.CheckoutOptions{
Branch: plumbing.NewBranchReferenceName(branchOrCommit),
Force: true,
})
}
func (g libGitter) RepoDir(repo string) string {

View File

@@ -6,8 +6,8 @@ import (
"path/filepath"
"strings"
"github.com/go-git/go-git/v5"
"github.com/micro/go-micro/v2/runtime/local/source"
git "gopkg.in/src-d/go-git.v4"
)
// Source retrieves source code