github.com/Benchkram/bob@v0.0.0-20220321080157-7c8f3876e225/test/setup/reposetup/create.go (about)

     1  package reposetup
     2  
     3  import (
     4  	"fmt"
     5  	"path/filepath"
     6  
     7  	git "github.com/go-git/go-git/v5"
     8  )
     9  
    10  func createAndFillRepo(basePath, name string) error {
    11  	const isBare = false
    12  
    13  	repoPath := filepath.Join(basePath, name)
    14  	repo, err := git.PlainInit(repoPath, isBare)
    15  	if err != nil {
    16  		return fmt.Errorf("failed to create repo %q: %w", repoPath, err)
    17  	}
    18  
    19  	if err := fillRepo(*repo, repoPath); err != nil {
    20  		return fmt.Errorf("failed to fill repo %q: %w", repoPath, err)
    21  	}
    22  
    23  	return nil
    24  }