コード例 #1
0
ファイル: showfrozen.go プロジェクト: nicholascapo/depman
//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
}
コード例 #2
0
ファイル: util.go プロジェクト: nicholascapo/depman
// PrintDep displays a dependency based on the --silent and --verbose flags
func PrintDep(name string, version string, repo string, stale bool) {
	var staleMarker string

	if stale {
		staleMarker = " *"
	}

	if !silent {
		if verbose {
			logger.Output(2, indent()+colors.Blue(name)+colors.Yellow(" ("+version+")")+" "+repo+staleMarker)
		} else {
			logger.Output(2, indent()+colors.Blue(name)+colors.Yellow(" ("+version+")")+staleMarker)
		}
	}
}
コード例 #3
0
ファイル: showfrozen.go プロジェクト: nicholascapo/depman
//Read - get top-level frozen dependencies
func Read(deps dep.DependencyMap) (result string) {
	var err error
	var resultMap = make(map[string]*dep.Dependency)

	util.Print(colors.Yellow("NOTE: This will not reflect the state of the remote unless you have just run `depman install`."))

	for k, v := range deps.Map {
		if v.Type == dep.TypeGitClone && v.Alias == "" {
			util.PrintIndent(colors.Red("Error: Repo '" + k + "' Type '" + v.Type + "' requires 'alias' field (defined in " + deps.Path + ")"))
			continue
		}

		v.Version, err = v.VCS.GetHead(v)
		if err != nil {
			util.Fatal(err)
		}

		resultMap[k] = v
	}

	//not changing the logic in the loop because we might want to change the print format later
	for _, v := range resultMap {
		result += fmt.Sprintf("%s %s\n", v.Repo, v.Version)
	}

	return
}
コード例 #4
0
ファイル: dep.go プロジェクト: nicholascapo/depman
// SetupVCS configures the VCS depending on the type
func (d *Dependency) SetupVCS(name string) (err error) {
	switch d.Type {
	case TypeGitClone:
		if d.Alias == "" {
			util.PrintIndent(colors.Red("Error: Dependency " + name + ": Repo '" + d.Repo + "' Type '" + d.Type + "' requires 'alias' field"))
			err = ErrMissingAlias
			return
		}

		d.VCS = new(Git)
	case TypeGit:
		d.VCS = new(Git)
	case TypeBzr:
		d.VCS = new(Bzr)
	case TypeHg:
		d.VCS = new(Hg)
	default:
		util.PrintIndent(colors.Red(d.Repo + ": Unknown repository type (" + d.Type + "), skipping..."))
		util.PrintIndent(colors.Red("Valid Repository types: " + TypeGit + ", " + TypeHg + ", " + TypeBzr + ", " + TypeGitClone))
		err = ErrUnknownType
	}

	if d.Type != TypeGitClone && d.Alias != "" {
		util.Print(colors.Yellow("Warning: " + d.Repo + ": 'alias' field only allowed in dependencies with type 'git-clone', skipping..."))
		d.Alias = ""
	}

	return
}
コード例 #5
0
ファイル: upgrade.go プロジェクト: nicholascapo/depman
// Print displays a message if a newer version of depman is available
// this should only be called after Check()
func Print() {
	if !checkCalled {
		util.Fatal(colors.Red("You must call upgrade.Check() before upgrade.Print()"))
	}

	// if the command used was self-upgrade, we can just return
	if selfCalled {
		return
	}

	ref := <-channel

	if checkError != nil {
		util.Verbose(colors.Yellow("Upgrade Check Error: " + checkError.Error()))
	}

	if ref != none {
		fmt.Println(colors.Yellow(fmt.Sprintf(message, ref)))
	}
}
コード例 #6
0
ファイル: install.go プロジェクト: pombredanne/depman
// Check for duplicate dependency
// if same name and same version, skip
// if same name and different version, exit
// if different name, add to set, don't skip
func duplicate(d dep.Dependency, set map[string]string) (skip bool) {
	version, installed := set[d.Repo]
	if installed && version != d.Version {
		util.Print(colors.Red("ERROR    : Duplicate dependency with different versions detected"))
		util.Print(colors.Red("Repo     : " + d.Repo))
		util.Fatal(colors.Red("Versions : " + d.Version + "\t" + version))
	} else if installed {
		util.VerboseIndent(colors.Yellow("Skipping previously installed dependency: ") + d.Repo)
		skip = true
	} else {
		set[d.Repo] = d.Version
	}
	return
}
コード例 #7
0
ファイル: timelock.go プロジェクト: nicholascapo/depman
// Clear clears the cache, returns true if the cache was cleared
func Clear() (cleared bool) {
	cleared = clear

	if clear {
		parts := strings.Split(os.Getenv("GOPATH"), ":")
		cacheFile = filepath.Join(parts[0], cacheFileName)

		util.Print(colors.Yellow("Clearing cache file: " + cacheFile))

		_, err := os.Stat(cacheFile)
		if err != nil {
			return
		}

		err = os.Remove(cacheFile)
		if err != nil {
			util.Fatal(err)
		}
	}

	return
}