Browse Source

Added gopm get -gopath

pull/103/head
Unknown 11 years ago
parent
commit
1b1bd986b8
  1. 2
      cmd/build.go
  2. 28
      cmd/get.go
  3. 2
      doc/github.go
  4. 2
      doc/google.go
  5. 2
      gopm.go

2
cmd/build.go

@ -17,6 +17,7 @@ package cmd
import (
"github.com/codegangsta/cli"
"github.com/gpmgo/gopm/doc"
"github.com/gpmgo/gopm/log"
)
@ -31,6 +32,7 @@ gopm build <go build commands>`,
}
func runBuild(ctx *cli.Context) {
doc.LoadLocalNodes()
genNewGoPath(ctx, false)
log.Trace("Building...")

28
cmd/get.go

@ -51,6 +51,7 @@ Can specify one or more: gopm get beego@tag:v0.9.0 github.com/beego/bee
If no argument is supplied, then gopmfile must be present`,
Action: runGet,
Flags: []cli.Flag{
cli.BoolFlag{"gopath", "download package(s) to GOPATH"},
cli.BoolFlag{"force", "force to update pakcage(s) and dependencies"},
cli.BoolFlag{"example", "download dependencies for example(s)"},
},
@ -70,8 +71,19 @@ func runGet(ctx *cli.Context) {
doc.HomeDir = strings.Replace(doc.RawHomeDir, "~", hd, -1)
doc.LoadPkgNameList(doc.HomeDir + "/data/pkgname.list")
installRepoPath = doc.HomeDir + "/repos"
log.Log("Local repository path: %s", installRepoPath)
if ctx.Bool("gopath") {
installRepoPath = com.GetGOPATHs()[0]
if !com.IsDir(installRepoPath) {
log.Error("Get", "Fail to start command")
log.Fatal("", "GOPATH does not exist: "+installRepoPath)
}
log.Log("Indicate GOPATH: %s", installRepoPath)
installRepoPath += "/src"
} else {
installRepoPath = doc.HomeDir + "/repos"
log.Log("Local repository path: %s", installRepoPath)
}
// Check number of arguments.
switch len(ctx.Args()) {
@ -80,6 +92,7 @@ func runGet(ctx *cli.Context) {
default:
getByPath(ctx)
}
}
func getByGopmfile(ctx *cli.Context) {
@ -183,7 +196,7 @@ func downloadPackages(ctx *cli.Context, nodes []*doc.Node) {
// Check if it is a valid remote path.
if doc.IsValidRemotePath(n.ImportPath) {
installPath := installRepoPath + "/" + doc.GetProjectPath(n.ImportPath)
if len(n.Value) > 0 {
if len(n.Value) > 0 && !ctx.Bool("gopath") {
installPath += "." + n.Value
}
@ -279,6 +292,15 @@ func downloadPackage(ctx *cli.Context, nod *doc.Node) (*doc.Node, []string) {
os.RemoveAll(installRepoPath + "/" + doc.GetProjectPath(nod.ImportPath) + "/")
return nil, nil
}
suf := "." + nod.Value
if len(suf) == 1 {
suf = ""
}
if ctx.Bool("gopath") && len(suf) > 0 {
os.RemoveAll(installRepoPath + "/" + nod.ImportPath)
os.Rename(installRepoPath+"/"+nod.ImportPath+suf, installRepoPath+"/"+nod.ImportPath)
}
return nod, imports
}

2
doc/github.go

@ -70,7 +70,7 @@ func getGithubDoc(client *http.Client, match map[string]string, installRepoPath
break COMMIT_LOOP
}
}
if etag == nod.Revision {
if etag == nod.Revision && !ctx.Bool("gopath") {
log.Log("GET Package hasn't changed: %s", nod.ImportPath)
return nil, nil
}

2
doc/google.go

@ -64,7 +64,7 @@ func getGoogleDoc(client *http.Client, match map[string]string, installRepoPath
if m := googleRevisionRe.FindSubmatch(p); m == nil {
log.Error("GET", "Fail to get revision")
log.Error("", err.Error())
} else {
} else if !ctx.Bool("gopath") {
etag := string(m[1])
if etag == nod.Revision {
log.Log("GET Package hasn't changed: %s", nod.ImportPath)

2
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.5.6.1130"
const APP_VER = "0.5.7.1130"
// //cmd.CmdSearch,
// cmdClean,

Loading…
Cancel
Save