예제 #1
0
func (s *TimelockSuite) TestIsStale(c *C) {
	cache = make(map[string]time.Time)

	old := new(dep.Dependency)
	old.Repo = "old"

	new := new(dep.Dependency)
	new.Repo = "new"

	cache["old"] = time.Now().Add(-2 * time.Hour)
	cache["new"] = time.Now().Add(-1 * time.Minute)

	c.Check(IsStale(old), Equals, true)
	c.Check(IsStale(new), Equals, false)

}
예제 #2
0
파일: add.go 프로젝트: pombredanne/depman
// Add interactively prompts the user for details of a dependency, adds it to deps.json, and writes out the file
func Add(deps dep.DependencyMap, name string) {
	var cont = true
	_, exists := deps.Map[name]
	if exists {
		util.Fatal(colors.Red("Dependency '" + name + "'' is already defined, pick another name."))
	}

	util.Print(colors.Blue("Adding: ") + name)

	for cont {
		d := new(dep.Dependency)
		d.Type = promptType("Type", "git, git-clone, hg, bzr")
		if d.Type == dep.TypeGitClone {
			d.Repo = promptString("Repo", "git url")
		} else {
			d.Repo = promptString("Repo", "go import")
		}
		d.Version = promptString("Version", "hash, branch, or tag")
		if d.Type == dep.TypeGitClone {
			d.Alias = promptString("Alias", "where to install the repo")
		}
		deps.Map[name] = d
		cont = promptBool("Add another", "y/N")
	}

	for name, d := range deps.Map {
		err := d.SetupVCS(name)
		if err != nil {
			delete(deps.Map, name)
		}

	}

	err := deps.Write()
	if err != nil {
		util.Fatal(colors.Red("Error Writing " + deps.Path + ": " + err.Error()))
	}

	install.Install(deps)

	return
}
예제 #3
0
// Self upgrades this version of depman to the latest on the master branch
func Self() {
	deps := dep.New()
	d := new(dep.Dependency)
	d.Repo = "github.com/vube/depman"
	d.Version = "master"
	d.Type = "git"
	d.SetupVCS("depman")

	deps.Map["depman"] = d

	install.Recurse = false
	install.Install(deps)
	install.Recurse = true
	util.RunCommand("go install github.com/vube/depman")
}