code: func (r *Repo) Prepare() error {
  	// check if directory exists or is empty
  	// if not, create directory
  	fs, err := gos.ReadDir(r.Path)
  	if err != nil || len(fs) == 0 {
  		return gos.MkdirAll(r.Path, os.FileMode(0755))
  	}
  
  	// validate git repo
  	isGit := false
  	for _, f := range fs {
  		if f.IsDir() && f.Name() == ".git" {
  			isGit = true
  			break
  		}
  	}
  
  	if isGit {
  		// check if same repository
  		var repoURL string
  		if repoURL, err = r.originURL(); err == nil {
  			if strings.TrimSuffix(repoURL, ".git") == strings.TrimSuffix(r.URL.Val(), ".git") {
  				r.pulled = true
  				return nil
  			}
  		}
  		if err != nil {
  			return fmt.Errorf("cannot retrieve repo url for %v Error: %v", r.Path, err)
  		}
  		return fmt.Errorf("another git repo '%v' exists at %v", repoURL, r.Path)
  	}
  	return fmt.Errorf("cannot git clone into %v, directory not empty", r.Path)
  }
docs: // Prepare prepares for a git pull
  // and validates the configured directory