Skip to content

Commit

Permalink
[app][git] run real command for clone
Browse files Browse the repository at this point in the history
  • Loading branch information
at15 committed Aug 10, 2016
1 parent 0189e7f commit 0483809
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
11 changes: 8 additions & 3 deletions app/git/clone.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package git

import (
"github.com/dyweb/Ayi/util"
)

// CloneFromURL will clone a repository based on short url or normal git clone url
func CloneFromURL(repoURL string) error {
// get the remote from url
Expand All @@ -14,7 +18,8 @@ func CloneFromURL(repoURL string) error {

// Clone clones a remote git repo
func Clone(r Remote) error {
log.Info(r.GetSSH())
log.Info("git clone " + r.GetSSH() + " " + GetRepoBasePath() + "/" + r.Repo)
return nil
// log.Info("git clone " + r.GetSSH() + " " + GetCloneDirectory(r))
cmdStr := "git clone " + r.GetSSH() + " " + GetCloneDirectory(r)
log.Info(cmdStr)
return util.RunCommand(cmdStr)
}
11 changes: 11 additions & 0 deletions app/git/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package git
import (
"os"
"path/filepath"
"strings"

"github.com/spf13/viper"
)
Expand All @@ -21,3 +22,13 @@ func GetRepoBasePath() string {
}
return ""
}

// GetCloneDirectory return path for clone destination
func GetCloneDirectory(r Remote) string {
base := GetRepoBasePath()
if base == "" {
return ""
}
// git clone does not accept windows format path, so all /
return strings.Replace(base+"/"+r.Host+"/"+r.Owner+"/"+r.Repo, "\\", "/", -1)
}
2 changes: 1 addition & 1 deletion cmd/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var gitCloneCmd = &cobra.Command{
repoURL := args[0]
err := git.CloneFromURL(repoURL)
if err != nil {
log.Warn(err.Error())
log.Error(err.Error())
return
}
// TODO: clone may need to return more information
Expand Down

0 comments on commit 0483809

Please sign in to comment.