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:
@@ -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 {
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user