MCPcopy Index your code
hub / github.com/rilldata/rill / createCommit

Function createCommit

runtime/pkg/gitutil/gitcmdwrapper_test.go:438–462  ·  view source on GitHub ↗

createCommit creates a file and commits it to the repository

(t *testing.T, repoPath, fileName, fileContent, commitMessage string)

Source from the content-addressed store, hash-verified

436
437// createCommit creates a file and commits it to the repository
438func createCommit(t *testing.T, repoPath, fileName, fileContent, commitMessage string) {
439 filePath := filepath.Join(repoPath, fileName)
440 err := os.WriteFile(filePath, []byte(fileContent), 0644)
441 require.NoError(t, err, "failed to create file")
442
443 cmd := exec.Command("git", "-C", repoPath, "add", fileName)
444 _, err = cmd.Output()
445 if err != nil {
446 var execErr *exec.ExitError
447 if errors.As(err, &execErr) {
448 require.NoError(t, err, "failed to stage file"+fmt.Sprintf(": %s", execErr.Stderr))
449 }
450 require.NoError(t, err, "failed to stage file")
451 }
452
453 cmd = exec.Command("git", "-C", repoPath, "commit", "-m", commitMessage)
454 _, err = cmd.Output()
455 if err != nil {
456 var execErr *exec.ExitError
457 if errors.As(err, &execErr) {
458 require.NoError(t, err, "failed to commit file"+fmt.Sprintf(": %s", execErr.Stderr))
459 }
460 require.NoError(t, err, "failed to commit file")
461 }
462}
463
464// setupGitConfig sets up the git configuration for the repository at repoPath
465func setupGitConfig(t *testing.T, repoPath string) {

Callers 3

TestMergeWithStrategyFunction · 0.70
TestFetchBranchesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected