diff --git a/.gitignore b/.gitignore index 9997532ad..f7b0bca42 100644 --- a/.gitignore +++ b/.gitignore @@ -22,5 +22,4 @@ _testmain.go *.exe gpm -data/ -repo/ \ No newline at end of file +data/ \ No newline at end of file diff --git a/README.md b/README.md index ca0a17e32..18f91c638 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ gpm(Go Package Manager) is a Go package manage tool for search, install, update ## Todo -- Command `build` add current path to GOPATH temporary. +- Command `remove` is for removing packages. - Add gpm working principle design. - Add support for downloading tarballs from user sources. - After downloaded all packages in bundles or snapshots, need to check if all dependencies have been downloaded as well. @@ -26,7 +26,7 @@ gpm(Go Package Manager) is a Go package manage tool for search, install, update - Command `check` is for checking and downloading all missing dependencies. - Command `daemon` is for auto-compile web applications when debug it locally. - Command `update` is for checking updates. -- Command `remove` is for removing packages. - Command `search` is for searching packages. - Add feature "struct generator". - i18n support for Chinese. +- Add built-in application version in order to backup data when users update. diff --git a/conf/gpm.toml b/conf/gpm.toml index 6455717c9..e8253dfa0 100644 --- a/conf/gpm.toml +++ b/conf/gpm.toml @@ -1,7 +1,7 @@ # This is a configuration file for gpm with toml format. title = "gpm(Go Package Manager)" -version = "v0.1.3 Build 0522" +version = "v0.1.4 Build 0522" username = "" password = "" user_language = "en-US" diff --git a/doc/bitbucket.go b/doc/bitbucket.go index df3d97787..6aea175c2 100644 --- a/doc/bitbucket.go +++ b/doc/bitbucket.go @@ -23,9 +23,8 @@ var ( // GetBitbucketDoc downloads tarball from bitbucket.org. func GetBitbucketDoc(client *http.Client, match map[string]string, installGOPATH string, node *Node, cmdFlags map[string]bool) ([]string, error) { - commit := node.Value // Check version control. - if m := bitbucketEtagRe.FindStringSubmatch(commit); m != nil { + if m := bitbucketEtagRe.FindStringSubmatch(node.Value); m != nil { match["vcs"] = m[1] } else { var repo struct { @@ -39,10 +38,10 @@ func GetBitbucketDoc(client *http.Client, match map[string]string, installGOPATH // bundle and snapshot will have commit 'B' and 'S', // but does not need to download dependencies. - isCheckImport := len(commit) == 0 + isCheckImport := len(node.Value) == 0 // Check if download with specific revision. - if isCheckImport || len(commit) == 1 { + if isCheckImport || len(node.Value) == 1 { tags := make(map[string]string) for _, nodeType := range []string{"branches", "tags"} { var nodes map[string]struct { @@ -63,7 +62,7 @@ func GetBitbucketDoc(client *http.Client, match map[string]string, installGOPATH return nil, err } } else { - match["commit"] = commit + match["commit"] = node.Value } // We use .tar.gz here. @@ -78,6 +77,7 @@ func GetBitbucketDoc(client *http.Client, match map[string]string, installGOPATH projectPath := expand("bitbucket.org/{owner}/{repo}", match) installPath := installGOPATH + "/src/" + projectPath + node.ImportPath = projectPath // Remove old files. os.RemoveAll(installPath + "/") @@ -142,12 +142,6 @@ func GetBitbucketDoc(client *http.Client, match map[string]string, installGOPATH } } - node.Value = commit - /* node := &Node{ - ImportPath: projectPath, - Commit: commit, - }*/ - var imports []string // Check if need to check imports. diff --git a/doc/github.go b/doc/github.go index bb8fe5c51..63d3adf92 100644 --- a/doc/github.go +++ b/doc/github.go @@ -103,6 +103,7 @@ func GetGithubDoc(client *http.Client, match map[string]string, installGOPATH st projectPath := expand("github.com/{owner}/{repo}", match) installPath := installGOPATH + "/src/" + projectPath + node.ImportPath = projectPath // Remove old files. os.RemoveAll(installPath + "/") diff --git a/doc/google.go b/doc/google.go index 947c4c073..aa60895fe 100644 --- a/doc/google.go +++ b/doc/google.go @@ -50,9 +50,8 @@ func getGoogleVCS(client *http.Client, match map[string]string) error { // GetGoogleDoc downloads raw files from code.google.com. func GetGoogleDoc(client *http.Client, match map[string]string, installGOPATH string, node *Node, cmdFlags map[string]bool) ([]string, error) { setupGoogleMatch(match) - commit := node.Value // Check version control. - if m := googleEtagRe.FindStringSubmatch(commit); m != nil { + if m := googleEtagRe.FindStringSubmatch(node.Value); m != nil { match["vcs"] = m[1] } else if err := getGoogleVCS(client, match); err != nil { return nil, err @@ -60,12 +59,15 @@ func GetGoogleDoc(client *http.Client, match map[string]string, installGOPATH st // bundle and snapshot will have commit 'B' and 'S', // but does not need to download dependencies. - isCheckImport := len(commit) == 0 + isCheckImport := len(node.Value) == 0 + if len(node.Value) == 1 { + node.Value = "" + } rootPath := expand("http://{subrepo}{dot}{repo}.googlecode.com/{vcs}{dir}/", match) // Scrape the repo browser to find the project revision and individual Go files. - p, err := httpGetBytes(client, rootPath+"?r="+commit, nil) + p, err := httpGetBytes(client, rootPath+"?r="+node.Value, nil) if err != nil { return nil, err } @@ -78,6 +80,7 @@ func GetGoogleDoc(client *http.Client, match map[string]string, installGOPATH st projectPath := expand("code.google.com/p/{repo}{dot}{subrepo}{dir}", match) installPath := installGOPATH + "/src/" + projectPath + node.ImportPath = projectPath // Remove old files. os.RemoveAll(installPath + "/") @@ -90,7 +93,7 @@ func GetGoogleDoc(client *http.Client, match map[string]string, installGOPATH st fname := strings.Split(string(m[1]), "?")[0] files = append(files, &source{ name: fname, - rawURL: expand("http://{subrepo}{dot}{repo}.googlecode.com/{vcs}{dir}/{0}", match, fname) + "?r=" + commit, + rawURL: expand("http://{subrepo}{dot}{repo}.googlecode.com/{vcs}{dir}/{0}", match, fname) + "?r=" + node.Value, }) } @@ -128,17 +131,11 @@ func GetGoogleDoc(client *http.Client, match map[string]string, installGOPATH st } } - err = downloadFiles(client, match, rootPath, installPath+"/", commit, dirs) + err = downloadFiles(client, match, rootPath, installPath+"/", node.Value, dirs) if err != nil { return nil, err } - node.Value = commit - /* node := &Node{ - ImportPath: projectPath, - Commit: commit, - }*/ - var imports []string // Check if need to check imports. diff --git a/doc/launchpad.go b/doc/launchpad.go index 677a837f5..ecca7da9e 100644 --- a/doc/launchpad.go +++ b/doc/launchpad.go @@ -35,17 +35,17 @@ func GetLaunchpadDoc(client *http.Client, match map[string]string, installGOPATH return nil, err } } - commit := node.Value + // bundle and snapshot will have commit 'B' and 'S', // but does not need to download dependencies. - isCheckImport := len(commit) == 0 + isCheckImport := len(node.Value) == 0 var downloadPath string // Check if download with specific revision. - if isCheckImport || len(commit) == 1 { + if isCheckImport || len(node.Value) == 1 { downloadPath = expand("https://bazaar.launchpad.net/+branch/{repo}/tarball", match) } else { - downloadPath = expand("https://bazaar.launchpad.net/+branch/{repo}/tarball/"+commit, match) + downloadPath = expand("https://bazaar.launchpad.net/+branch/{repo}/tarball/"+node.Value, match) } // Scrape the repo browser to find the project revision and individual Go files. @@ -56,6 +56,7 @@ func GetLaunchpadDoc(client *http.Client, match map[string]string, installGOPATH projectPath := expand("launchpad.net/{repo}", match) installPath := installGOPATH + "/src/" + projectPath + node.ImportPath = projectPath // Remove old files. os.RemoveAll(installPath + "/") @@ -120,12 +121,6 @@ func GetLaunchpadDoc(client *http.Client, match map[string]string, installGOPATH } } - node.Value = commit - /* node := &Node{ - ImportPath: projectPath, - Commit: commit, - }*/ - var imports []string // Check if need to check imports. diff --git a/install.go b/install.go index 86c6f1206..a5fe86cbc 100644 --- a/install.go +++ b/install.go @@ -240,6 +240,9 @@ func downloadPackages(nodes []*doc.Node) { // saveNode saves node into local nodes. func saveNode(n *doc.Node) { + // Node dependencies list. + n.Deps = nil + // Check if this node exists. for i, v := range localNodes { if n.ImportPath == v.ImportPath { diff --git a/repo/bundles/test_bundle.json b/repo/bundles/test_bundle.json new file mode 100644 index 000000000..8eee69831 --- /dev/null +++ b/repo/bundles/test_bundle.json @@ -0,0 +1,58 @@ +{ + "id": 0, + "user_id": 0, + "bundle_name": "bundle_test", + "comment": "just a test", + "timestamp": 0, + "nodes": [ + { + "import_path": "github.com/astaxie/beego", + "type": "tag", + "value": "v0.6.0", + "deps":[ + { + "import_path": "github.com/russross/blackfriday", + "type": "commit", + "value": "", + "deps": null + }, + { + "import_path": "code.google.com/p/vitess/go/memcache", + "type": "commit", + "value": "", + "deps": null + }, + { + "import_path": "github.com/garyburd/redigo/redis", + "type": "commit", + "value": "aa31b4b202d4ea44ca45b3c93d71575c02ba35dc", + "deps": null + }, + { + "import_path": "github.com/go-sql-driver/mysql", + "type": "tag", + "value": "v1.0", + "deps": null + } + ] + }, + { + "import_path": "github.com/coocood/qbs", + "type": "branch", + "value": "master", + "deps": null + }, + { + "import_path": "bitbucket.org/zombiezen/gopdf/pdf", + "type": "commit", + "value": "", + "deps": null + }, + { + "import_path": "launchpad.net/goamz/aws", + "type": "commit", + "value": "", + "deps": null + } + ] +} \ No newline at end of file