Browse Source

Bug fixed

pull/103/head
Unknown 11 years ago
parent
commit
679b61cd48
  1. 38
      cmd/gopath.go

38
cmd/gopath.go

@ -49,12 +49,18 @@ func getGopmPkgs(dirPath string, isTest bool) (pkgs map[string]*doc.Pkg, err err
} }
if !doc.IsGoRepoPath(name) { if !doc.IsGoRepoPath(name) {
if builds != nil { if builds != nil {
if dep, ok := builds[name]; ok { if info, ok := builds[name]; ok {
// TODO: need version // Check version.
pkgs[name] = &doc.Pkg{ImportPath: dep} if i := strings.Index(info, ":"); i > -1 {
pkgs[name] = &doc.Pkg{
ImportPath: name,
Type: info[:i],
Value: info[i+1:],
}
continue continue
} }
} }
}
pkgs[name] = doc.NewDefaultPkg(name) pkgs[name] = doc.NewDefaultPkg(name)
} }
} }
@ -82,16 +88,21 @@ func getChildPkgs(ctx *cli.Context, cpath string, ppkg *doc.Pkg, cachePkgs map[s
if !pkgInCache(name, cachePkgs) { if !pkgInCache(name, cachePkgs) {
var newPath string var newPath string
if !build.IsLocalImport(name) { if !build.IsLocalImport(name) {
suf := "." + pkg.Value
if len(suf) == 1 {
suf = ""
}
newPath = filepath.Join(installRepoPath, pkg.ImportPath) newPath = filepath.Join(installRepoPath, pkg.ImportPath)
if pkgName != "" && strings.HasPrefix(pkg.ImportPath, pkgName) { if pkgName != "" && strings.HasPrefix(pkg.ImportPath, pkgName) {
newPath = filepath.Join(curPath, pkg.ImportPath[len(pkgName)+1:]) newPath = filepath.Join(curPath, pkg.ImportPath[len(pkgName)+1:]+suf)
} else { } else {
if !com.IsExist(newPath) { if !com.IsExist(newPath + suf) {
var t, ver string = doc.BRANCH, "" node := doc.NewNode(pkg.ImportPath, pkg.ImportPath,
node := doc.NewNode(pkg.ImportPath, pkg.ImportPath, t, ver, true) pkg.Type, pkg.Value, true)
nodes := []*doc.Node{node} nodes := []*doc.Node{node}
downloadPackages(ctx, nodes) downloadPackages(ctx, nodes)
// should handler download failed // TODO: Should handler download failed
} }
} }
} else { } else {
@ -214,8 +225,13 @@ func genNewGoPath(ctx *cli.Context, isTest bool) {
os.RemoveAll(newGoPathSrc) os.RemoveAll(newGoPathSrc)
os.MkdirAll(newGoPathSrc, os.ModePerm) os.MkdirAll(newGoPathSrc, os.ModePerm)
for name, _ := range cachePkgs { for name, pkg := range cachePkgs {
oldPath := filepath.Join(installRepoPath, name) suf := "." + pkg.Value
if len(suf) == 1 {
suf = ""
}
oldPath := filepath.Join(installRepoPath, name) + suf
newPath := filepath.Join(newGoPathSrc, name) newPath := filepath.Join(newGoPathSrc, name)
paths := strings.Split(name, "/") paths := strings.Split(name, "/")
var isExistP bool var isExistP bool
@ -236,7 +252,7 @@ func genNewGoPath(ctx *cli.Context, isTest bool) {
} }
if !isExistP { if !isExistP {
log.Log("Linking %s", name) log.Log("Linking %s", name+suf)
err = autoLink(oldPath, newPath) err = autoLink(oldPath, newPath)
if err != nil { if err != nil {
log.Error("", "Fail to make link") log.Error("", "Fail to make link")

Loading…
Cancel
Save