// 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 }
// 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 }
// 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") }
// 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") } }
// 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 }
// Fetch fetches a git repo func (g *Git) Fetch(d *Dependency) (err error) { err = util.RunCommand("git fetch origin") return }
// Update updates a git repo func (g *Git) Update(d *Dependency) (err error) { if g.isBranch(d.Version) { err = util.RunCommand("git pull") } return }
// Checkout updates a bzr repo func (b *Bzr) Checkout(d *Dependency) (err error) { err = util.RunCommand("bzr up --revision " + d.Version) return }
// Fetch pulls in a bzr repo func (b *Bzr) Fetch(d *Dependency) (err error) { err = util.RunCommand("bzr pull") return }
// 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 }
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 }
func (h *Hg) Checkout(d *Dependency) (err error) { err = util.RunCommand("hg up " + d.Version) return }
func (h *Hg) Fetch(d *Dependency) (err error) { err = util.RunCommand("hg pull") return }