From a7125daad6aa64fd5645081b47d1db0de6d45753 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 11 Mar 2014 23:28:45 -0400 Subject: [PATCH 1/4] Bug fix --- cmd/gen.go | 2 +- cmd/get.go | 4 ++-- doc/utils.go | 25 +++++++++++++------------ gopm.go | 2 +- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/cmd/gen.go b/cmd/gen.go index 6abd821d8..314a65e9e 100644 --- a/cmd/gen.go +++ b/cmd/gen.go @@ -57,7 +57,7 @@ func runGen(ctx *cli.Context) { targetPath := parseTarget(gf.MustValue("target", "path")) // Get dependencies. imports := doc.GetAllImports([]string{workDir}, targetPath, ctx.Bool("example")) - + log.Log("%v", imports) for _, p := range imports { p = doc.GetProjectPath(p) // Skip subpackage(s) of current project. diff --git a/cmd/get.go b/cmd/get.go index 7742d2d2d..fac5890f6 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -233,8 +233,8 @@ func downloadPackages(ctx *cli.Context, nodes []*doc.Node) { n.ImportPath, n.Type, doc.CheckNodeValue(n.Value)) // Only copy when no version control. - if ctx.Bool("gopath") && com.IsExist(installPath) || - len(getVcsName(gopathDir)) == 0 { + if ctx.Bool("gopath") && (com.IsExist(installPath) || + len(getVcsName(gopathDir)) == 0) { copyToGopath(installPath, gopathDir) } continue diff --git a/doc/utils.go b/doc/utils.go index 327a29dea..558ab2ac9 100644 --- a/doc/utils.go +++ b/doc/utils.go @@ -56,26 +56,27 @@ func GetImports(absPath, importPath string, example bool) []string { } } - //fis := GetDirsInfo(absPath) + fis := GetDirsInfo(absPath) absPath += "/" - // Load too much, skip for now. - // dirs := make([]string, 0) - // for _, fi := range fis { - // if fi.IsDir() && !strings.Contains(fi.Name(), VENDOR) { - // dirs = append(dirs, absPath+fi.Name()) - // } - // } - imports := make([]string, 0, len(pkg.Imports)) for _, p := range pkg.Imports { if !IsGoRepoPath(p) && !strings.HasPrefix(p, importPath) { imports = append(imports, p) } } - // if len(dirs) > 0 { - // imports = append(imports, GetAllImports(dirs, importPath, example)...) - // } + + // TODO: Load too much + dirs := make([]string, 0, len(imports)) + for _, fi := range fis { + if fi.IsDir() && !strings.Contains(fi.Name(), VENDOR) { + dirs = append(dirs, absPath+fi.Name()) + } + } + + if len(dirs) > 0 { + imports = append(imports, GetAllImports(dirs, importPath, example)...) + } return imports } diff --git a/gopm.go b/gopm.go index 5f00d2467..1b454ce47 100644 --- a/gopm.go +++ b/gopm.go @@ -29,7 +29,7 @@ import ( // Test that go1.1 tag above is included in builds. main.go refers to this definition. const go11tag = true -const APP_VER = "0.6.3.0301" +const APP_VER = "0.6.3.0311" // //cmd.CmdSearch, // cmdClean, From 5a213c08345a2f93c39a52bcfe1f6c94798c5340 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 11 Mar 2014 23:38:22 -0400 Subject: [PATCH 2/4] Bug fix --- cmd/get.go | 3 --- doc/github.go | 5 +++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/get.go b/cmd/get.go index fac5890f6..a6f616b86 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -191,9 +191,6 @@ func copyToGopath(srcPath, destPath string) { // if the commit is empty string, then it downloads all dependencies, // otherwise, it only downloada package with specific commit only. func downloadPackages(ctx *cli.Context, nodes []*doc.Node) { - for _, node := range nodes { - fmt.Println(node) - } // Check all packages, they may be raw packages path. for _, n := range nodes { // Check if local reference diff --git a/doc/github.go b/doc/github.go index ffd7a77ea..0bd62c391 100644 --- a/doc/github.go +++ b/doc/github.go @@ -63,8 +63,9 @@ func getGithubDoc(client *http.Client, match map[string]string, installRepoPath err := com.HttpGetJSON(client, com.Expand("https://api.github.com/repos/{owner}/{repo}/git/refs?{cred}", match), &refs) if err != nil { - log.Error("GET", "Fail to get revision") - log.Error("", err.Error()) + log.Warn("GET", "Fail to get revision") + log.Warn("", err.Error()) + log.Help("Try 'gopm config github' to set and gain more API calls") break } From dd724eb8be6b6eb8088d2649af4c503f80fcf04c Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 12 Mar 2014 05:05:25 -0400 Subject: [PATCH 3/4] Add res section in gopmfile --- cmd/gen.go | 13 ++++++++++++- gopm.go | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cmd/gen.go b/cmd/gen.go index 314a65e9e..1c78171e0 100644 --- a/cmd/gen.go +++ b/cmd/gen.go @@ -41,6 +41,8 @@ Make sure you run this command in the root path of a go project.`, }, } +var commonRes = []string{"views", "templates", "static", "public", "conf"} + func runGen(ctx *cli.Context) { setup(ctx) @@ -55,7 +57,7 @@ func runGen(ctx *cli.Context) { } targetPath := parseTarget(gf.MustValue("target", "path")) - // Get dependencies. + // Get and set dependencies. imports := doc.GetAllImports([]string{workDir}, targetPath, ctx.Bool("example")) log.Log("%v", imports) for _, p := range imports { @@ -71,6 +73,15 @@ func runGen(ctx *cli.Context) { } } + // Get and set resources. + res := make([]string, 0, len(commonRes)) + for _, cr := range commonRes { + if com.IsExist(cr) { + res = append(res, cr) + } + } + gf.SetValue("res", "include", strings.Join(res, "|")) + err = goconfig.SaveConfigFile(gf, ".gopmfile") if err != nil { log.Error("gen", "Fail to save gopmfile:") diff --git a/gopm.go b/gopm.go index 1b454ce47..0695a5ad9 100644 --- a/gopm.go +++ b/gopm.go @@ -29,7 +29,7 @@ import ( // Test that go1.1 tag above is included in builds. main.go refers to this definition. const go11tag = true -const APP_VER = "0.6.3.0311" +const APP_VER = "0.6.3.0312" // //cmd.CmdSearch, // cmdClean, From c40e2850731ab5af13d012d4e965d692cd2a27b9 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 13 Mar 2014 16:58:57 -0400 Subject: [PATCH 4/4] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 918477308..7a3748cad 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ USAGE: gopm [global options] command [command options] [arguments...] VERSION: - 0.6.3.0220 + 0.6.3.0311 COMMANDS: get fetch remote package(s) and dependencies to local repository