diff --git a/cmd/kratos/internal/base/repo.go b/cmd/kratos/internal/base/repo.go index ce54bf743..aeb8c2424 100644 --- a/cmd/kratos/internal/base/repo.go +++ b/cmd/kratos/internal/base/repo.go @@ -18,9 +18,11 @@ type Repo struct { // NewRepo new a repository manager. func NewRepo(url string) *Repo { + start := strings.Index(url, "//") + end := strings.LastIndex(url, "/") return &Repo{ url: url, - home: kratosHomeWithDir("repo"), + home: kratosHomeWithDir("repo/" + url[start+2:end]), } } @@ -31,8 +33,8 @@ func (r *Repo) Path() string { return path.Join(r.home, r.url[start+1:end]) } -// Pull fetchs the repository from remote url. -func (r *Repo) Pull(ctx context.Context, url string) error { +// Pull fetch the repository from remote url. +func (r *Repo) Pull(ctx context.Context) error { repo, err := git.PlainOpen(r.Path()) if err != nil { return err @@ -53,7 +55,7 @@ func (r *Repo) Pull(ctx context.Context, url string) error { // Clone clones the repository to cache path. func (r *Repo) Clone(ctx context.Context) error { if _, err := os.Stat(r.Path()); !os.IsNotExist(err) { - return r.Pull(ctx, r.url) + return r.Pull(ctx) } _, err := git.PlainCloneContext(ctx, r.Path(), false, &git.CloneOptions{ URL: r.url,