Browse Source

supports local path for gopmfile deps package's value

pull/103/head
Lunny Xiao 11 years ago
parent
commit
061cf9aef8
  1. 6
      cmd/cmd.go
  2. 4
      cmd/get.go
  3. 21
      cmd/gopath.go
  4. 3
      doc/struct.go
  5. 2
      gopm.go

6
cmd/cmd.go

@ -18,6 +18,7 @@ import (
"os"
"strings"
"github.com/Unknwon/com"
"github.com/codegangsta/cli"
"github.com/gpmgo/gopm/doc"
@ -56,6 +57,11 @@ func validPath(info string) (string, string) {
l := len(infos)
switch {
case l == 1:
// for local imports
if com.IsFile(infos[0]) {
return doc.LOCAL, infos[0]
}
return doc.BRANCH, ""
case l == 2:
switch infos[1] {

4
cmd/get.go

@ -180,6 +180,10 @@ func copyToGopath(srcPath, destPath string) {
func downloadPackages(ctx *cli.Context, nodes []*doc.Node) {
// Check all packages, they may be raw packages path.
for _, n := range nodes {
// Check if local reference
if n.Type == doc.LOCAL {
continue
}
// Check if it is a valid remote path.
if doc.IsValidRemotePath(n.ImportPath) {
gopathDir := path.Join(installGopath, n.ImportPath)

21
cmd/gopath.go

@ -52,6 +52,13 @@ func getGopmPkgs(dirPath string, isTest bool) (pkgs map[string]*doc.Pkg, err err
Value: info[i+1:],
}
continue
} else if com.IsDir(info) {
pkgs[name] = &doc.Pkg{
ImportPath: name,
Type: doc.LOCAL,
Value: info,
}
continue
}
}
}
@ -81,7 +88,7 @@ func getChildPkgs(ctx *cli.Context, cpath string, ppkg *doc.Pkg, cachePkgs map[s
pkg.RootPath = doc.GetProjectPath(pkg.ImportPath)
if !pkgInCache(pkg.RootPath, cachePkgs) {
var newPath string
if !build.IsLocalImport(name) {
if !build.IsLocalImport(name) && pkg.Type != doc.LOCAL {
suf := versionSuffix(pkg.Value)
pkgPath := strings.Replace(
pkg.ImportPath, pkg.RootPath, pkg.RootPath+suf, 1)
@ -101,8 +108,12 @@ func getChildPkgs(ctx *cli.Context, cpath string, ppkg *doc.Pkg, cachePkgs map[s
// TODO: Should handler download failed
}
}
} else {
if pkg.Type == doc.LOCAL {
newPath, err = filepath.Abs(pkg.Value)
} else {
newPath, err = filepath.Abs(name)
}
if err != nil {
return err
}
@ -216,7 +227,13 @@ func genNewGoPath(ctx *cli.Context, isTest bool) {
for name, pkg := range cachePkgs {
suf := versionSuffix(pkg.Value)
oldPath := filepath.Join(installRepoPath, name) + suf
var oldPath string
if pkg.Type == doc.LOCAL {
oldPath, _ = filepath.Abs(pkg.Value)
} else {
oldPath = filepath.Join(installRepoPath, name) + suf
}
newPath := filepath.Join(newGoPathSrc, name)
paths := strings.Split(name, "/")
var isExistP, isCurChild bool

3
doc/struct.go

@ -32,13 +32,14 @@ const (
TAG = "tag"
BRANCH = "branch"
COMMIT = "commit"
LOCAL = "local"
)
type Pkg struct {
ImportPath string
RootPath string
Type string
Value string // Branch, tag or commit.
Value string // Branch, tag, commit or local.
}
func (pkg *Pkg) VerString() string {

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.6.0.1209"
const APP_VER = "0.6.0.1210"
// //cmd.CmdSearch,
// cmdClean,

Loading…
Cancel
Save