(t *testing.T, repoPath, fileName, fileContent, commitMessage string)
| 352 | } |
| 353 | |
| 354 | func createCommit(t *testing.T, repoPath, fileName, fileContent, commitMessage string) { |
| 355 | t.Helper() |
| 356 | filePath := filepath.Join(repoPath, fileName) |
| 357 | |
| 358 | // Create directory if needed |
| 359 | dir := filepath.Dir(filePath) |
| 360 | if dir != repoPath { |
| 361 | err := os.MkdirAll(dir, 0755) |
| 362 | require.NoError(t, err, "failed to create directory") |
| 363 | } |
| 364 | |
| 365 | err := os.WriteFile(filePath, []byte(fileContent), 0644) |
| 366 | require.NoError(t, err, "failed to create file") |
| 367 | |
| 368 | cmd := exec.Command("git", "-C", repoPath, "add", fileName) |
| 369 | _, err = cmd.Output() |
| 370 | if err != nil { |
| 371 | var execErr *exec.ExitError |
| 372 | if errors.As(err, &execErr) { |
| 373 | require.NoError(t, err, "failed to stage file: "+string(execErr.Stderr)) |
| 374 | } |
| 375 | require.NoError(t, err, "failed to stage file") |
| 376 | } |
| 377 | |
| 378 | cmd = exec.Command("git", "-C", repoPath, "commit", "-m", commitMessage) |
| 379 | _, err = cmd.Output() |
| 380 | if err != nil { |
| 381 | var execErr *exec.ExitError |
| 382 | if errors.As(err, &execErr) { |
| 383 | require.NoError(t, err, "failed to commit file: "+string(execErr.Stderr)) |
| 384 | } |
| 385 | require.NoError(t, err, "failed to commit file") |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | func createRemoteCommit(t *testing.T, remoteDir, fileName, fileContent, commitMessage string) { |
| 390 | t.Helper() |
no test coverage detected