Browse Source

bug fixed

pull/103/head
Lunny Xiao 11 years ago
parent
commit
05c95c0832
  1. 2
      cmd/cmd.go
  2. 29
      cmd/gopath.go

2
cmd/cmd.go

@ -20,7 +20,7 @@ import (
"strings" "strings"
) )
const APP_VER = "0.5.0.1103" const APP_VER = "0.5.1.1104"
var ( var (
AppPath string AppPath string

29
cmd/gopath.go

@ -71,12 +71,16 @@ func getChildPkgs(cpath string, ppkg *doc.Pkg, cachePkgs map[string]*doc.Pkg) er
var newPath string var newPath string
if !build.IsLocalImport(name) { if !build.IsLocalImport(name) {
newPath = filepath.Join(installRepoPath, pkg.ImportPath) newPath = filepath.Join(installRepoPath, pkg.ImportPath)
if !com.IsExist(newPath) { if pkgName != "" && strings.HasPrefix(pkg.ImportPath, pkgName) {
var t, ver string = doc.BRANCH, "" newPath = filepath.Join(curPath, pkg.ImportPath[len(pkgName)+1:])
node := doc.NewNode(pkg.ImportPath, pkg.ImportPath, t, ver, true) } else {
nodes := []*doc.Node{node} if !com.IsExist(newPath) {
downloadPackages(nodes) var t, ver string = doc.BRANCH, ""
// should handler download failed node := doc.NewNode(pkg.ImportPath, pkg.ImportPath, t, ver, true)
nodes := []*doc.Node{node}
downloadPackages(nodes)
// should handler download failed
}
} }
} else { } else {
newPath, err = filepath.Abs(name) newPath, err = filepath.Abs(name)
@ -96,8 +100,12 @@ func getChildPkgs(cpath string, ppkg *doc.Pkg, cachePkgs map[string]*doc.Pkg) er
return nil return nil
} }
var pkgName string
var curPath string
func genNewGoPath() { func genNewGoPath() {
curPath, err := os.Getwd() var err error
curPath, err = os.Getwd()
if err != nil { if err != nil {
com.ColorLog("[ERRO] %v\n", err) com.ColorLog("[ERRO] %v\n", err)
return return
@ -110,7 +118,6 @@ func genNewGoPath() {
} }
gf := doc.NewGopmfile() gf := doc.NewGopmfile()
var pkgName string
gpmPath := filepath.Join(curPath, doc.GopmFileName) gpmPath := filepath.Join(curPath, doc.GopmFileName)
if com.IsExist(gpmPath) { if com.IsExist(gpmPath) {
com.ColorLog("[INFO] loading .gopmfile ...\n") com.ColorLog("[INFO] loading .gopmfile ...\n")
@ -121,14 +128,14 @@ func genNewGoPath() {
} }
} }
installRepoPath = strings.Replace(reposDir, "~", hd, -1)
cachePkgs := make(map[string]*doc.Pkg)
if target, ok := gf.Sections["target"]; ok { if target, ok := gf.Sections["target"]; ok {
pkgName = target.Props["path"] pkgName = target.Props["path"]
com.ColorLog("[INFO] target name is %v\n", pkgName) com.ColorLog("[INFO] target name is %v\n", pkgName)
} }
installRepoPath = strings.Replace(reposDir, "~", hd, -1)
cachePkgs := make(map[string]*doc.Pkg)
err = getChildPkgs(curPath, nil, cachePkgs) err = getChildPkgs(curPath, nil, cachePkgs)
if err != nil { if err != nil {
com.ColorLog("[ERRO] %v\n", err) com.ColorLog("[ERRO] %v\n", err)

Loading…
Cancel
Save