From 113a4420e6e1e1c7a73efd3951bef775109c52de Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 22 May 2013 10:13:36 -0400 Subject: [PATCH] command install add support for use tag, branch or commit for packages in github.com --- doc/struct.go | 2 +- install.go | 30 ++++++++++++++---------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/doc/struct.go b/doc/struct.go index cc348e1b6..47e911c7e 100644 --- a/doc/struct.go +++ b/doc/struct.go @@ -14,7 +14,7 @@ import ( type Node struct { ImportPath string `json:"import_path"` Type, Value string - Deps []*Node `json:"-"` // Dependencies. + Deps []*Node // Dependencies. } // Bundle represents a bundle. diff --git a/install.go b/install.go index 548feafa1..e08fc3730 100644 --- a/install.go +++ b/install.go @@ -148,26 +148,24 @@ func runInstall(cmd *Command, args []string) { fmt.Println("Well done.") } +// chekcDeps checks dependencies of nodes. +func chekcDeps(nodes []*doc.Node) (depnodes []*doc.Node) { + for _, n := range nodes { + // Make sure it will not download all dependencies automatically. + if len(n.Value) == 0 { + n.Value = "B" + } + depnodes = append(depnodes, n) + depnodes = append(depnodes, chekcDeps(n.Deps)...) + } + return depnodes +} + // checkLocalBundles checks if the bundle is in local file system. func checkLocalBundles(bundle string) (nodes []*doc.Node) { for _, b := range localBundles { if bundle == b.Name { - for _, n := range b.Nodes { - // Make sure it will not download all dependencies automatically. - if len(n.Value) == 0 { - n.Value = "B" - } - nodes = append(nodes, n) - - // Check dependencies. - for _, d := range n.Deps { - // Make sure it will not download all dependencies automatically. - if len(d.Value) == 0 { - d.Value = "B" - } - nodes = append(nodes, d) - } - } + nodes = append(nodes, chekcDeps(b.Nodes)...) return nodes } }