From bf14e02a1bad738138329dc5484db920e23023b2 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 27 Aug 2013 12:25:47 +0800 Subject: [PATCH] Huge imporve for downloading repos on google code --- .gitignore | 1 + cmd/get.go | 1 - doc/google.go | 18 +++++++++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index f78fbe263..2b4fd370c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ gopm *.exe *.exe~ +repos/ \ No newline at end of file diff --git a/cmd/get.go b/cmd/get.go index d9ac9d66e..6a502cbfc 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -18,7 +18,6 @@ import ( "errors" "fmt" "os/user" - //"path" "strings" "github.com/gpmgo/gopm/doc" diff --git a/doc/google.go b/doc/google.go index e9e3000f7..d1e2c48f2 100644 --- a/doc/google.go +++ b/doc/google.go @@ -52,16 +52,28 @@ func getGoogleDoc(client *http.Client, match map[string]string, installRepoPath // Remove old files. os.RemoveAll(installPath + "/") match["tag"] = nod.Value - err := packer.PackToFile(match["importPath"], installPath+".zip", match) + + ext := ".zip" + if match["vcs"] == "svn" { + ext = ".tar.gz" + } + + err := packer.PackToFile(match["importPath"], installPath+ext, match) if err != nil { return nil, err } - dirs, err := com.Unzip(installPath+".zip", path.Dir(installPath)) + var dirs []string + if match["vcs"] != "svn" { + dirs, err = com.Unzip(installPath+ext, path.Dir(installPath)) + } else { + dirs, err = com.UnTarGz(installPath+ext, path.Dir(installPath)) + } + if err != nil { return nil, err } - os.Remove(installPath + ".zip") + os.Remove(installPath + ext) os.Rename(path.Dir(installPath)+"/"+dirs[0], installPath) // Check if need to check imports.