MCPcopy Create free account
hub / github.com/celer-pkg/celer / createGitRepo

Function createGitRepo

pkgcache/cache_repo_test.go:158–175  ·  view source on GitHub ↗

createGitRepo sets up a minimal git repo and returns its directory and commit hash.

(t *testing.T, tmpDir string)

Source from the content-addressed store, hash-verified

156
157// createGitRepo sets up a minimal git repo and returns its directory and commit hash.
158func createGitRepo(t *testing.T, tmpDir string) (repoDir, commitHash string) {
159 t.Helper()
160 repoDir = filepath.Join(tmpDir, "git-repo")
161 if err := os.MkdirAll(repoDir, os.ModePerm); err != nil {
162 t.Fatal(err)
163 }
164 if err := os.WriteFile(filepath.Join(repoDir, "hello.txt"), []byte("hello-git"), os.ModePerm); err != nil {
165 t.Fatal(err)
166 }
167 if err := git.InitAsLocalRepo(repoDir, "init"); err != nil {
168 t.Fatal(err)
169 }
170 hash, err := git.GetCommitHash(repoDir)
171 if err != nil {
172 t.Fatal(err)
173 }
174 return repoDir, hash
175}
176
177// ---- Store tests ----
178

Callers 2

TestStore_GitRepoFunction · 0.85
TestRestore_GitRepoFunction · 0.85

Calls 4

InitAsLocalRepoFunction · 0.92
GetCommitHashFunction · 0.92
MkdirAllMethod · 0.80
WriteFileMethod · 0.80

Tested by

no test coverage detected