Browse Source

Added option “—update, -u” for build command

pull/103/head
Unknown 11 years ago
parent
commit
9691733ace
  1. 4
      README.md
  2. 1
      cmd/build.go
  3. 4
      cmd/cmd.go
  4. 9
      cmd/get.go
  5. 2
      cmd/gopath.go
  6. 8
      gopm.go

4
README.md

@ -19,7 +19,7 @@ USAGE:
gopm [global options] command [command options] [arguments...] gopm [global options] command [command options] [arguments...]
VERSION: VERSION:
0.6.0.1211 0.6.1.0110
COMMANDS: COMMANDS:
get fetch remote package(s) and dependencies to local repository get fetch remote package(s) and dependencies to local repository
@ -32,7 +32,7 @@ COMMANDS:
GLOBAL OPTIONS: GLOBAL OPTIONS:
--noterm disable color output --noterm disable color output
--version print the version --version, -v print the version
--help, -h show help --help, -h show help
``` ```

1
cmd/build.go

@ -34,6 +34,7 @@ and execute 'go build'
gopm build <go build commands>`, gopm build <go build commands>`,
Action: runBuild, Action: runBuild,
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{"update, u", "update pakcage(s) and dependencies if any"},
cli.BoolFlag{"verbose, v", "show process details"}, cli.BoolFlag{"verbose, v", "show process details"},
}, },
} }

4
cmd/cmd.go

@ -81,3 +81,7 @@ func versionSuffix(value string) string {
} }
return "" return ""
} }
func isSubpackage(rootPath, targetPath string) bool {
return strings.HasSuffix(workDir, rootPath) || strings.HasPrefix(rootPath, targetPath)
}

9
cmd/get.go

@ -126,7 +126,7 @@ func getByGopmfile(ctx *cli.Context) {
for _, p := range imports { for _, p := range imports {
p = doc.GetProjectPath(p) p = doc.GetProjectPath(p)
// Skip subpackage(s) of current project. // Skip subpackage(s) of current project.
if strings.HasSuffix(workDir, p) || strings.HasPrefix(p, targetPath) { if isSubpackage(p, targetPath) {
continue continue
} }
node := doc.NewNode(p, p, doc.BRANCH, "", true) node := doc.NewNode(p, p, doc.BRANCH, "", true)
@ -145,7 +145,6 @@ func getByGopmfile(ctx *cli.Context) {
} }
func getByPath(ctx *cli.Context) { func getByPath(ctx *cli.Context) {
return
nodes := make([]*doc.Node, 0, len(ctx.Args())) nodes := make([]*doc.Node, 0, len(ctx.Args()))
for _, info := range ctx.Args() { for _, info := range ctx.Args() {
pkgPath := info pkgPath := info
@ -214,6 +213,10 @@ func downloadPackages(ctx *cli.Context, nodes []*doc.Node) {
n.RootPath = doc.GetProjectPath(n.ImportPath) n.RootPath = doc.GetProjectPath(n.ImportPath)
installPath := path.Join(installRepoPath, n.RootPath) + versionSuffix(n.Value) installPath := path.Join(installRepoPath, n.RootPath) + versionSuffix(n.Value)
if isSubpackage(n.RootPath, ".") {
continue
}
// Indicates whether need to download package again. // Indicates whether need to download package again.
if n.IsFixed() && com.IsExist(installPath) { if n.IsFixed() && com.IsExist(installPath) {
n.IsGetDepsOnly = true n.IsGetDepsOnly = true
@ -388,6 +391,8 @@ func updateByVcs(vcs, dirPath string) error {
if len(stderr) > 0 { if len(stderr) > 0 {
log.Error("", "Error: "+stderr) log.Error("", "Error: "+stderr)
} }
case "svn":
log.Error("", "Error: not support svn yet")
} }
return nil return nil
} }

2
cmd/gopath.go

@ -101,7 +101,7 @@ func getChildPkgs(ctx *cli.Context, cpath string, ppkg *doc.Pkg, cachePkgs map[s
if pkgName != "" && strings.HasPrefix(pkg.ImportPath, pkgName) { if pkgName != "" && strings.HasPrefix(pkg.ImportPath, pkgName) {
newPath = filepath.Join(curPath, strings.TrimPrefix(pkg.ImportPath, pkgName)) newPath = filepath.Join(curPath, strings.TrimPrefix(pkg.ImportPath, pkgName))
} else { } else {
if !com.IsExist(newPath) { if !com.IsExist(newPath) || ctx.Bool("update") {
node := doc.NewNode(pkg.ImportPath, pkg.ImportPath, node := doc.NewNode(pkg.ImportPath, pkg.ImportPath,
pkg.Type, pkg.Value, true) pkg.Type, pkg.Value, true)
nodes := []*doc.Node{node} nodes := []*doc.Node{node}

8
gopm.go

@ -52,11 +52,11 @@ func main() {
app.Version = APP_VER app.Version = APP_VER
app.Commands = []cli.Command{ app.Commands = []cli.Command{
cmd.CmdGet, cmd.CmdGet,
//cmd.CmdBin, cmd.CmdBin,
cmd.CmdGen, cmd.CmdGen,
//cmd.CmdRun, cmd.CmdRun,
//cmd.CmdBuild, cmd.CmdBuild,
//cmd.CmdInstall, cmd.CmdInstall,
//cmd.CmdUpdate, //cmd.CmdUpdate,
//cmd.CmdTest, //cmd.CmdTest,
} }

Loading…
Cancel
Save