//ReadRecursively - get frozen dependencies recursively func ReadRecursively(deps dep.DependencyMap, set map[string]string) (result string) { var err error if set == nil { util.Print(colors.Yellow("NOTE: This will not reflect the state of the remote unless you have just run `depman install`.")) set = make(map[string]string) } for name, d := range deps.Map { var subPath string var depsFile string var subDeps dep.DependencyMap if _, ok := set[d.Repo]; ok { continue } if d.Type == dep.TypeGitClone && d.Alias == "" { util.PrintIndent(colors.Red("Error: Repo '" + name + "' Type '" + d.Type + "' requires 'alias' field (defined in " + deps.Path + ")")) continue } { var temp string temp, err = d.VCS.GetHead(d) if err != nil { util.Fatal(err) } set[d.Repo] = temp result += fmt.Sprintf("%s %s\n", d.Repo, temp) } subPath = d.Path() // Recursive depsFile = util.UpwardFind(subPath, dep.DepsFile) if depsFile != "" { subDeps, err = dep.Read(depsFile) if err == nil { result += ReadRecursively(subDeps, set) } else { util.Print(colors.Yellow("Error reading deps from '" + subDeps.Path + "': " + err.Error())) } } } return }
// recursively install a DependencyMap func recursiveInstall(deps dep.DependencyMap, set map[string]string) (err error) { for name, d := range deps.Map { start := time.Now() if duplicate(*d, set) { continue } stale := timelock.IsStale(d.Repo) util.PrintDep(name, d.Version, d.Repo, stale) subPath := d.Path() err = d.VCS.Clone(d) if err != nil { continue } util.Cd(subPath) if clean { d.VCS.Clean(d) } if stale { util.VerboseIndent(" # repo is stale, fetching") err = d.VCS.Fetch(d) if err != nil { continue } } err = d.VCS.Checkout(d) if err != nil { continue } if stale { err = d.VCS.Update(d) if err != nil { continue } } util.VerboseIndent(fmt.Sprintf("# time to install: %.3fs", time.Since(start).Seconds())) // Recursive depsFile := util.UpwardFind(subPath, dep.DepsFile) if depsFile != "" && Recurse { subDeps, err := dep.Read(depsFile) if err != nil { util.Print(colors.Red("Error reading deps from '" + depsFile + "': " + err.Error())) result.RegisterError() } else { util.IncreaseIndent() recursiveInstall(subDeps, set) util.DecreaseIndent() } } } return }