createRemoteMergeCommit builds a merge commit on the remote by cloning it, creating a feature branch and a divergent commit, then merging with --no-ff and pushing. After it returns, the remote `branch` has 2 non-merge commits + 1 merge commit on top of its previous tip.
(t *testing.T, remoteDir, branch string)
| 675 | // After it returns, the remote `branch` has 2 non-merge commits + 1 merge commit |
| 676 | // on top of its previous tip. |
| 677 | func createRemoteMergeCommit(t *testing.T, remoteDir, branch string) { |
| 678 | workingDir := t.TempDir() |
| 679 | cmd := exec.Command("git", "clone", remoteDir, workingDir) |
| 680 | require.NoError(t, cmd.Run(), "failed to clone remote repository") |
| 681 | setupGitConfig(t, workingDir) |
| 682 | |
| 683 | cmd = exec.Command("git", "-C", workingDir, "checkout", "-b", "remote-feature") |
| 684 | require.NoError(t, cmd.Run(), "failed to create remote feature branch") |
| 685 | createCommit(t, workingDir, "remote-feature.txt", "feature", "remote feature commit") |
| 686 | |
| 687 | cmd = exec.Command("git", "-C", workingDir, "checkout", branch) |
| 688 | require.NoError(t, cmd.Run(), "failed to switch to branch") |
| 689 | createCommit(t, workingDir, "remote-main.txt", "main", "remote main commit") |
| 690 | |
| 691 | cmd = exec.Command("git", "-C", workingDir, "merge", "--no-ff", "remote-feature", "-m", "remote merge") |
| 692 | require.NoError(t, cmd.Run(), "failed to create remote merge commit") |
| 693 | |
| 694 | cmd = exec.Command("git", "-C", workingDir, "push", "origin", branch) |
| 695 | require.NoError(t, cmd.Run(), "failed to push merge to remote") |
| 696 | } |
| 697 | |
| 698 | // setupGitConfig sets up the git configuration for the repository at repoPath. |
| 699 | func setupGitConfig(t *testing.T, repoPath string) { |
no test coverage detected