From 1177eadf8bcbe40d2eb0fa997ccdbf0b45b0cdcc Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 28 Aug 2013 09:02:03 +0800 Subject: [PATCH 1/3] Litter fix --- cmd/serve.go | 4 ++-- doc/google.go | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/serve.go b/cmd/serve.go index 0b2a38555..5afe15565 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -149,7 +149,7 @@ func saveNode(nod *doc.Node) error { url := fmt.Sprintf("http://%v:%v/add?%v", "localhost", "8991", nod.ImportPath) resp, err := http.Get(url) if err != nil { - com.ColorLog("%v\n", err.Error()) + com.ColorLog("[ERRO] Fail to save node[ %s ]\n", err) return err } defer resp.Body.Close() @@ -430,7 +430,7 @@ func addHandler(w http.ResponseWriter, r *http.Request) { if nod != nil { err := addNode(nod) if err != nil { - fmt.Println(err) + com.ColorLog("[ERRO] SEVER: Cannot add node[ %s ]\n", err) } } else { fmt.Println(key) diff --git a/doc/google.go b/doc/google.go index 849abbe9d..aafe8a452 100644 --- a/doc/google.go +++ b/doc/google.go @@ -15,6 +15,7 @@ package doc import ( + "errors" "net/http" "os" "path" @@ -56,6 +57,7 @@ func getGoogleDoc(client *http.Client, match map[string]string, installRepoPath ext := ".zip" if match["vcs"] == "svn" { ext = ".tar.gz" + com.ColorLog("[WARN] SVN detected, may take very long time.\n") } err := packer.PackToFile(match["importPath"], installPath+ext, match) @@ -70,6 +72,10 @@ func getGoogleDoc(client *http.Client, match map[string]string, installRepoPath dirs, err = com.UnTarGz(installPath+ext, path.Dir(installPath)) } + if len(dirs) == 0 { + return nil, errors.New("No file in repository") + } + if err != nil { return nil, err } From 53a37e6504c1d7c7f33ce8dd9b88459ad265ef74 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 29 Aug 2013 21:02:37 +0800 Subject: [PATCH 2/3] Done download repos on google code --- doc/google.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/google.go b/doc/google.go index aafe8a452..f363a3b23 100644 --- a/doc/google.go +++ b/doc/google.go @@ -38,16 +38,15 @@ func getGoogleDoc(client *http.Client, match map[string]string, installRepoPath } var installPath string + projectPath := GetProjectPath(nod.ImportPath) if nod.ImportPath == nod.DownloadURL { suf := "." + nod.Value if len(suf) == 1 { suf = "" } - projectPath := expand("code.google.com/p/{repo}{dot}{subrepo}{dir}", match) installPath = installRepoPath + "/" + projectPath + suf - nod.ImportPath = projectPath } else { - installPath = installRepoPath + "/" + nod.ImportPath + installPath = installRepoPath + "/" + projectPath } // Remove old files. From 393d351826724308297bde21b7fd0982811a097e Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 30 Aug 2013 00:17:43 +0800 Subject: [PATCH 3/3] Code fix --- cmd/get.go | 2 +- cmd/serve.go | 2 +- doc/utils.go | 18 ------------------ 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/cmd/get.go b/cmd/get.go index 70a91fdf5..6ae456e8c 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -120,7 +120,7 @@ func runGet(cmd *Command, args []string) { return } - hd, err := doc.GetHomeDir() + hd, err := com.HomeDir() if err != nil { com.ColorLog("[ERRO] Fail to get current user[ %s ]\n", err) return diff --git a/cmd/serve.go b/cmd/serve.go index 5afe15565..be4b18c1a 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -332,7 +332,7 @@ func runningStatus() (int, int, int) { } func startService(listen string) { - homeDir, err := doc.GetHomeDir() + homeDir, err := com.HomeDir() if err != nil { fmt.Println(err) return diff --git a/doc/utils.go b/doc/utils.go index e550e3d5c..ebcbf5d72 100644 --- a/doc/utils.go +++ b/doc/utils.go @@ -16,10 +16,8 @@ package doc import ( "os" - "os/user" "path" "regexp" - "runtime" "strings" "github.com/Unknwon/com" @@ -620,22 +618,6 @@ func IsGoRepoPath(importPath string) bool { return standardPath[importPath] } -func GetHomeDir() (string, error) { - if runtime.GOOS != "windows" { - curUser, err := user.Current() - if err != nil { - return "", err - } - return curUser.HomeDir, nil - } else { - hd, err := com.HomeDir() - if err != nil { - return "", err - } - return hd, nil - } -} - func CheckNodeValue(v string) string { if len(v) == 0 { return ""