From 8fe66176a5e6aeec855a4844b634806950d98fe0 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 10 Jan 2014 17:41:32 +0800 Subject: [PATCH] change isUnchangablePoint to Pkg's method IsFixed --- cmd/get.go | 14 +------------- doc/struct.go | 9 +++++++++ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/cmd/get.go b/cmd/get.go index 9157f351e..4eeb9a471 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -188,18 +188,6 @@ func copyToGopath(srcPath, destPath string) { log.Log("Package copied to GOPATH: %s", importPath) } -func isUnchangablePoint(nod *doc.Node) bool { - if len(nod.Value) == 0 { - return false - } - - switch nod.Type { - case doc.COMMIT, doc.TAG: - return true - } - return false -} - // downloadPackages downloads packages with certain commit, // if the commit is empty string, then it downloads all dependencies, // otherwise, it only downloada package with specific commit only. @@ -227,7 +215,7 @@ func downloadPackages(ctx *cli.Context, nodes []*doc.Node) { installPath := path.Join(installRepoPath, n.RootPath) + versionSuffix(n.Value) // Indicates whether need to download package again. - if isUnchangablePoint(n) && com.IsExist(installPath) { + if n.IsFixed() && com.IsExist(installPath) { n.IsGetDepsOnly = true } diff --git a/doc/struct.go b/doc/struct.go index 59258e8d9..02e91b5b4 100644 --- a/doc/struct.go +++ b/doc/struct.go @@ -42,6 +42,15 @@ type Pkg struct { Value string // Branch, tag, commit or local. } +// If the package is fixed and no need to updated. +// For commit, tag and local, it's fixed. For branch +func (pkg *Pkg) IsFixed() bool { + if pkg.Type == BRANCH || len(pkg.Value) == 0 { + return false + } + return true +} + func (pkg *Pkg) VerString() string { if pkg.Value == "" { return pkg.Type