Ejemplo n.º 1
0
func (s *TestSuite) TestDuplicate(c *C) {
	set := make(map[string]string)

	d := dep.Dependency{Repo: "repo", Version: "version", Type: "type"}
	c.Check(len(set), Equals, 0)

	// No dup
	skip := duplicate(d, set)
	c.Check(skip, Equals, false)
	c.Check(len(set), Equals, 1)
	v, ok := set["repo"]
	c.Check(ok, Equals, true)
	c.Check(v, Equals, "version")

	// dup same version
	util.SetVerbose(true)
	skip = duplicate(d, set)
	c.Check(len(set), Equals, 1)
	c.Check(s.buf.String(), Equals, "Skipping previously installed dependency: repo\n")
	c.Check(skip, Equals, true)

	s.buf.Truncate(0)

	// dup different version
	d.Version = "version2"
	skip = duplicate(d, set)
	c.Check(len(set), Equals, 1)
	out := "ERROR    : Duplicate dependency with different versions detected\nRepo     : repo\nVersions : version2\tversion\n"
	c.Check(s.buf.String(), Equals, out)
	c.Check(skip, Equals, false)

}
Ejemplo n.º 2
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)

}
Ejemplo n.º 3
0
// Add interactively prompts the user for details of a dependency, adds it to deps.json, writes out the file, and installs the dependencies
func Add(deps dep.DependencyMap, name string) {
	_, exists := deps.Map[name]
	if exists {
		util.Fatal(colors.Red("Dependency '" + name + "'' is already defined, pick another name."))
	}

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

	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

	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
}
Ejemplo n.º 4
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")
}