Skip to content

Commit e643765

Browse files
committed
Merge remote-tracking branch 'origin/merge-interactive-merge' into remote-delete
2 parents 858cd70 + d7c933b commit e643765

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

command/pr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ func prMerge(cmd *cobra.Command, args []string) error {
549549

550550
fmt.Fprintf(colorableOut(cmd), "%s %s pull request #%d\n", utils.Magenta("✔"), action, pr.Number)
551551

552-
if deleteBranch {
552+
if deleteBranch && !cmd.Flags().Changed("repo") {
553553
repo, err := api.GitHubRepo(apiClient, baseRepo)
554554
if err != nil {
555555
return err

command/pr_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,31 @@ func TestPrMerge(t *testing.T) {
10171017
}
10181018
}
10191019

1020+
func TestPrMerge_withRepoFlag(t *testing.T) {
1021+
initBlankContext("", "OWNER/REPO", "master")
1022+
http := initFakeHTTP()
1023+
http.StubResponse(200, bytes.NewBufferString(`{ "data": { "repository": {
1024+
"pullRequest": { "number": 1, "closed": false, "state": "OPEN"}
1025+
} } }`))
1026+
http.StubResponse(200, bytes.NewBufferString(`{"id": "THE-ID"}`))
1027+
1028+
cs, cmdTeardown := test.InitCmdStubber()
1029+
defer cmdTeardown()
1030+
1031+
eq(t, len(cs.Calls), 0)
1032+
1033+
output, err := RunCommand("pr merge 1 --merge -R stinky/boi")
1034+
if err != nil {
1035+
t.Fatalf("error running command `pr merge`: %v", err)
1036+
}
1037+
1038+
r := regexp.MustCompile(`Merged pull request #1`)
1039+
1040+
if !r.MatchString(output.String()) {
1041+
t.Fatalf("output did not match regexp /%s/\n> output\n%q\n", r, output.Stderr())
1042+
}
1043+
}
1044+
10201045
func TestPrMerge_deleteBranch(t *testing.T) {
10211046
initWithStubs("blueberries",
10221047
stubResponse{200, bytes.NewBufferString(`

git/git.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ func ReadBranchConfig(branch string) (cfg BranchConfig) {
204204
}
205205

206206
func DeleteLocalBranch(branch string) error {
207-
configCmd := GitCommand("branch", "-d", branch)
208-
_, err := run.PrepareCmd(configCmd).Output()
207+
branchCmd := GitCommand("branch", "-D", branch)
208+
err := run.PrepareCmd(branchCmd).Run()
209209
return err
210210
}
211211

@@ -223,7 +223,7 @@ func HasLocalBranch(branch string) bool {
223223

224224
func CheckoutBranch(branch string) error {
225225
configCmd := GitCommand("checkout", branch)
226-
_, err := run.PrepareCmd(configCmd).Output()
226+
err := run.PrepareCmd(configCmd).Run()
227227
return err
228228
}
229229

0 commit comments

Comments
 (0)