Пример #1
0
func ensureGDMExists(repo, localPath string, log func(string, ...interface{})) error {
	s, err := os.Stat(localPath)
	if err == nil && s.IsDir() {
		files, err := ioutil.ReadDir(localPath)
		if err != nil {
			return err
		}
		if len(files) != 0 {
			// The directory exists and is not empty, do nothing.
			if repo != "" {
				log("not pulling repo %q; directory already exist and is not empty: %q", repo, localPath)
			}
			return nil
		}
	}
	if err := config.EnsureDirExists(localPath); err != nil {
		return EnsureErrorResult(err)
	}
	sh, err := shell.DefaultInDir(localPath)
	if err != nil {
		return EnsureErrorResult(err)
	}
	g, err := git.NewClient(sh)
	if err != nil {
		return EnsureErrorResult(err)
	}
	log("cloning %q into %q ...", repo, localPath)
	if err := g.CloneRepo(repo, localPath); err != nil {
		return EnsureErrorResult(err)
	}
	log("done")
	return nil
}
Пример #2
0
func newLocalGitClient(sh LocalWorkDirShell) (v LocalGitClient, err error) {
	v.Client, err = git.NewClient(sh.Sh)
	return v, initErr(err, "initialising git client")
}