예제 #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)

}
예제 #2
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")
}
예제 #3
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
}