Exemplo n.º 1
0
// Clone clones d.Repo into d.Path() if d.Path does not exist, otherwise it will cd to d.Path() and run git fetch
func (g *Git) Clone(d *Dependency) (err error) {
	if !util.Exists(d.Path()) {
		if d.Type == TypeGitClone {
			err = util.RunCommand("git clone " + d.Repo + " " + d.Path())
		} else {
			err = util.RunCommand("go get -u " + d.Repo)
		}
	}
	return
}
Exemplo n.º 2
0
// Checkout uses the appropriate VCS to checkout the specified version of the code
func (g *Git) Checkout(d *Dependency) (err error) {
	err = util.RunCommand("git checkout " + d.Version)
	if err != nil {
		err = g.Fetch(d)
		if err == nil {
			err = util.RunCommand("git checkout " + d.Version)
		}
	}
	return
}
Exemplo n.º 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")
}
Exemplo n.º 4
0
// Self upgrades this version of depman to the latest on the master branch
func Self(version string) {
	selfCalled = true
	util.Print(colors.Blue("Upgrading depman..."))
	util.RunCommand("go get -u github.com/vube/depman")

	cmd := exec.Command("depman", "--version")
	out, err := cmd.CombinedOutput()
	if err != nil {
		result.RegisterError()
		util.Print(colors.Red(string(out)))
		return
	}

	newVersion := strings.TrimSuffix(strings.TrimPrefix(string(out), "Depman Version "), "\n")

	if newVersion != version {
		util.Print("Upgraded to Version " + newVersion)
	} else {
		util.Print("No upgrade found")
	}
}
Exemplo n.º 5
0
// Clean cleans a git repo: `git reset --hard HEAD ; git clean -fd`
func (g *Git) Clean(d *Dependency) {
	util.PrintIndent(colors.Red("Cleaning:") + colors.Blue(" git reset --hard HEAD"))
	util.RunCommand("git reset --hard HEAD")
	util.RunCommand("git clean -fd")
	return
}
Exemplo n.º 6
0
// Fetch fetches a git repo
func (g *Git) Fetch(d *Dependency) (err error) {
	err = util.RunCommand("git fetch origin")
	return
}
Exemplo n.º 7
0
// Update updates a git repo
func (g *Git) Update(d *Dependency) (err error) {
	if g.isBranch(d.Version) {
		err = util.RunCommand("git pull")
	}
	return
}
Exemplo n.º 8
0
// Checkout updates a bzr repo
func (b *Bzr) Checkout(d *Dependency) (err error) {
	err = util.RunCommand("bzr up --revision " + d.Version)
	return
}
Exemplo n.º 9
0
// Fetch pulls in a bzr repo
func (b *Bzr) Fetch(d *Dependency) (err error) {
	err = util.RunCommand("bzr pull")
	return
}
Exemplo n.º 10
0
// Clone clones a bzr repo
func (b *Bzr) Clone(d *Dependency) (err error) {
	if !util.Exists(d.Path()) {
		err = util.RunCommand("go get -u " + d.Repo)
	}
	return
}
Exemplo n.º 11
0
func (h *Hg) Clean(d *Dependency) {
	util.PrintIndent(colors.Red("Cleaning:") + colors.Blue(" hg up --clean "+d.Version))
	util.RunCommand("hg up --clean " + d.Version)
	return
}
Exemplo n.º 12
0
func (h *Hg) Checkout(d *Dependency) (err error) {
	err = util.RunCommand("hg up " + d.Version)
	return
}
Exemplo n.º 13
0
func (h *Hg) Fetch(d *Dependency) (err error) {
	err = util.RunCommand("hg pull")
	return
}