nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: lindell/multi-gitter
Pull request #281 (2022-09-21 19:38:40)

fix: better error message when the same feature and base branch is used
Related to: #278


Patch:
diff --git a/internal/multigitter/run.go b/internal/multigitter/run.go
index 0c658f4..c55e0ea 100755
--- a/internal/multigitter/run.go
+++ b/internal/multigitter/run.go
@@ -211,6 +211,10 @@ func (r *Runner) runSingleRepo(ctx context.Context, repo scm.Repository) (scm.Pu
 		baseBranch = repo.DefaultBranch()
 	}
 
+	if baseBranch == r.FeatureBranch {
+		return nil, errors.Errorf("both the feature branch and base branch was named %s, if you intended to push directly into the base branch, please use the `skip-pr` option", baseBranch)
+	}
+
 	err = sourceController.Clone(repo.CloneURL(), baseBranch)
 	if err != nil {
 		return nil, err


Test patch:
diff --git a/tests/table_test.go b/tests/table_test.go
index 6f24272..d8f3a52 100644
--- a/tests/table_test.go
+++ b/tests/table_test.go
@@ -906,6 +906,29 @@ Repositories with a successful run:
 				assert.False(t, fileExist(t, vcMock.Repositories[0].Path, "test_file"))
 			},
 		},
+
+		{
+			name: "same feature and base branch name",
+			vcCreate: func(t *testing.T) *vcmock.VersionController {
+				return &vcmock.VersionController{
+					Repositories: []vcmock.Repository{
+						createRepo(t, "owner", "should-not-change", "i like apples"),
+					},
+				}
+			},
+			args: []string{
+				"run",
+				"--author-name", "Test Author",
+				"--author-email", "test@example.com",
+				"-B", "master",
+				"-m", "custom message",
+				changerBinaryPath,
+			},
+			verify: func(t *testing.T, vcMock *vcmock.VersionController, runData runData) {
+				require.Len(t, vcMock.PullRequests, 0)
+				assert.Equal(t, "Both the feature branch and base branch was named master, if you intended to push directly into the base branch, please use the `skip-pr` option:\n  owner/should-not-change\n", runData.out)
+			},
+		},
 	}
 
 	for _, gitBackend := range gitBackends {