setupMirrorSourceRepo creates a local git repository with commits on two branches and a tag.
(t *testing.T)
| 26 | |
| 27 | // setupMirrorSourceRepo creates a local git repository with commits on two branches and a tag. |
| 28 | func setupMirrorSourceRepo(t *testing.T) string { |
| 29 | t.Helper() |
| 30 | dir := t.TempDir() |
| 31 | runGitCommand(t, dir, "init") |
| 32 | runGitCommand(t, dir, "checkout", "-b", "main") |
| 33 | runGitCommand(t, dir, "config", "user.name", "Test User") |
| 34 | runGitCommand(t, dir, "config", "user.email", "test@example.com") |
| 35 | |
| 36 | err := os.WriteFile(filepath.Join(dir, "readme.txt"), []byte("hello"), 0644) |
| 37 | require.NoError(t, err) |
| 38 | runGitCommand(t, dir, "add", "readme.txt") |
| 39 | runGitCommand(t, dir, "commit", "-m", "initial commit") |
| 40 | runGitCommand(t, dir, "tag", "v1.0") |
| 41 | |
| 42 | runGitCommand(t, dir, "checkout", "-b", "feature") |
| 43 | err = os.WriteFile(filepath.Join(dir, "feature.txt"), []byte("feature"), 0644) |
| 44 | require.NoError(t, err) |
| 45 | runGitCommand(t, dir, "add", "feature.txt") |
| 46 | runGitCommand(t, dir, "commit", "-m", "add feature") |
| 47 | return dir |
| 48 | } |
| 49 | |
| 50 | func runGitCommand(t *testing.T, dir string, args ...string) string { |
| 51 | t.Helper() |
no test coverage detected