Exemplo n.º 1
0
func (g *Git) Pull(repo *Repo, dir string) error {
	properUrl, err := repo.URLWithCredentials()
	if err != nil {
		return fmt.Errorf("Invalid URL: %v", err)
	}
	cmd := shell.WrapCommandOutput(g.Context, exec.Command("git", "pull", properUrl))
	cmd.Dir = dir
	return cmd.Run()
}
Exemplo n.º 2
0
func (g *Git) Clone(repo *Repo, intoDir string) error {
	// TODO: --single-branch?
	properUrl, err := repo.URLWithCredentials()
	if err != nil {
		return fmt.Errorf("Invalid URL: %v", err)
	}
	cmd := shell.WrapCommandOutput(g.Context, exec.Command("git", "clone", "-b", repo.Branch, properUrl, intoDir))
	if err = cmd.Start(); err != nil {
		return fmt.Errorf("Unable to clone: %v", err)
	}
	// Wait for completion
	if err = shell.WaitTimeout(cmd, 30*time.Second); err != nil {
		return fmt.Errorf("Failed clone: %v", err)
	}
	return nil
}
Exemplo n.º 3
0
func (g *Git) ResetHard(dir string) error {
	cmd := shell.WrapCommandOutput(g.Context, exec.Command("git", "reset", "--hard"))
	cmd.Dir = dir
	return cmd.Run()
}