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

Function createCommit

cli/pkg/gitutil/gitcmdwrapper_test.go:627–654  ·  view source on GitHub ↗
(t *testing.T, repoPath, fileName, fileContent, commitMessage string)

Source from the content-addressed store, hash-verified

625}
626
627func createCommit(t *testing.T, repoPath, fileName, fileContent, commitMessage string) {
628 filePath := filepath.Join(repoPath, fileName)
629 err := os.WriteFile(filePath, []byte(fileContent), 0644)
630 require.NoError(t, err, "failed to create file")
631
632 cmd := exec.Command("git", "-C", repoPath, "add", fileName)
633 _, err = cmd.Output()
634 if err != nil {
635 var execErr *exec.ExitError
636 if errors.As(err, &execErr) {
637 // This is error msg returned by git when pull fails
638 require.NoError(t, err, "failed to stage file"+fmt.Sprintf(": %s", execErr.Stderr))
639 }
640 require.NoError(t, err, "failed to stage file")
641 }
642
643 cmd = exec.Command("git", "-C", repoPath, "commit", "-m", commitMessage)
644 _, err = cmd.Output()
645 if err != nil {
646 var execErr *exec.ExitError
647 if errors.As(err, &execErr) {
648 // This is error msg returned by git when pull fails
649 require.NoError(t, err, "failed to commit file"+fmt.Sprintf(": %s", execErr.Stderr))
650 }
651 require.NoError(t, err, "failed to commit file")
652 }
653
654}
655
656func createRemoteCommit(t *testing.T, remoteDir, fileName, fileContent, commitMessage string) {
657 // Clone the bare repository to a temporary working directory

Calls

no outgoing calls

Tested by

no test coverage detected