Prefix branch names when checking out a PR locally
This PR changes the behavior of `gh pr checkout` to _always_ prefix local branch names with
`pr/<id>/<branch name>`. This prevents branch name collisions locally, which currently result in an
ugly git error.

![image](https://user-images.githubusercontent.com/98482/73798075-676b7f80-4777-11ea-97b8-52da30da1e22.png)

I also took the opportunity to split `prCheckout` into its own file. I have liked having `prCreate` split out like that and given how long `pr.go` has become it seemed like a good idea to split some more.


Closes #233

Suppose two different people use the GitHub web flow to submit patches to the same repository:

- PR `#1` with head `user1:patch-1`
- PR `#2` with head `user2:patch-1`

The default branch name for web flow is `patch-1` and a lot of people leave that unchanged.

We want to support both `gh pr checkout 1` and `gh pr checkout 2` used interchangeably, but right now the 2nd operation will fail because after the 1st operation, a local `patch-1` branch already exists, but is associated with another PR and trying to fast-forward it to the latest commits in `user2:patch-1` will fail on the git level due to unrelated histories.

Proposed solution: 

```sh
gh pr checkout 1 # Works like before,
gh pr checkout 2 # Issues warning on stderr that `patch-1` already exists and
                 # names the new branch with a unique name such as `user2-patch-1`.
```

https://github.slack.com/archives/CLLG3RMAR/p1579201119275200
Support `checkout` for PRs whose head matches an unrelated local branch
diff --git a/command/pr.go b/command/pr.go
index 624debac06e..38ee25c4e09 100644
--- a/command/pr.go
+++ b/command/pr.go
@@ -1,11 +1,8 @@
 package command
 
 import (
-	"errors"
 	"fmt"
 	"io"
-	"os"
-	"os/exec"
 	"regexp"
 	"strconv"
 	"strings"
@@ -46,17 +43,6 @@ A pull request can be supplied as argument in any of the following formats:
 - by URL, e.g. "https://github.com/OWNER/REPO/pull/123"; or
 - by the name of its head branch, e.g. "patch-1" or "OWNER:patch-1".`,
 }
-var prCheckoutCmd = &cobra.Command{
-	Use:   "checkout {<number> | <url> | <branch>}",
-	Short: "Check out a pull request in Git",
-	Args: func(cmd *cobra.Command, args []string) error {
-		if len(args) < 1 {
-			return errors.New("requires a PR number as an argument")
-		}
-		return nil
-	},
-	RunE: prCheckout,
-}
 var prListCmd = &cobra.Command{
 	Use:   "list",
 	Short: "List and filter pull requests in this repository",
@@ -386,95 +372,6 @@ func prSelectorForCurrentBranch(ctx context.Context) (prNumber int, prHeadRef st
 	return
 }
 
-func prCheckout(cmd *cobra.Command, args []string) error {
-	ctx := contextForCommand(cmd)
-	currentBranch, _ := ctx.Branch()
-	remotes, err := ctx.Remotes()
-	if err != nil {
-		return err
-	}
-	// FIXME: duplicates logic from fsContext.BaseRepo
-	baseRemote, err := remotes.FindByName("upstream", "github", "origin", "*")
-	if err != nil {
-		return err
-	}
-	apiClient, err := apiClientForContext(ctx)
-	if err != nil {
-		return err
-	}
-
-	pr, err := prFromArg(apiClient, baseRemote, args[0])
-	if err != nil {
-		return err
-	}
-
-	headRemote := baseRemote
-	if pr.IsCrossRepository {
-		headRemote, _ = remotes.FindByRepo(pr.HeadRepositoryOwner.Login, pr.HeadRepository.Name)
-	}
-
-	cmdQueue := [][]string{}
-
-	newBranchName := pr.HeadRefName
-	if headRemote != nil {
-		// there is an existing git remote for PR head
-		remoteBranch := fmt.Sprintf("%s/%s", headRemote.Name, pr.HeadRefName)
-		refSpec := fmt.Sprintf("+refs/heads/%s:refs/remotes/%s", pr.HeadRefName, remoteBranch)
-
-		cmdQueue = append(cmdQueue, []string{"git", "fetch", headRemote.Name, refSpec})
-
-		// local branch already exists
-		if git.VerifyRef("refs/heads/" + newBranchName) {
-			cmdQueue = append(cmdQueue, []string{"git", "checkout", newBranchName})
-			cmdQueue = append(cmdQueue, []string{"git", "merge", "--ff-only", fmt.Sprintf("refs/remotes/%s", remoteBranch)})
-		} else {
-			cmdQueue = append(cmdQueue, []string{"git", "checkout", "-b", newBranchName, "--no-track", remoteBranch})
-			cmdQueue = append(cmdQueue, []string{"git", "config", fmt.Sprintf("branch.%s.remote", newBranchName), headRemote.Name})
-			cmdQueue = append(cmdQueue, []string{"git", "config", fmt.Sprintf("branch.%s.merge", newBranchName), "refs/heads/" + pr.HeadRefName})
-		}
-	} else {
-		// no git remote for PR head
-
-		// avoid naming the new branch the same as the default branch
-		if newBranchName == pr.HeadRepository.DefaultBranchRef.Name {
-			newBranchName = fmt.Sprintf("%s/%s", pr.HeadRepositoryOwner.Login, newBranchName)
-		}
-
-		ref := fmt.Sprintf("refs/pull/%d/head", pr.Number)
-		if newBranchName == currentBranch {
-			// PR head matches currently checked out branch
-			cmdQueue = append(cmdQueue, []string{"git", "fetch", baseRemote.Name, ref})
-			cmdQueue = append(cmdQueue, []string{"git", "merge", "--ff-only", "FETCH_HEAD"})
-		} else {
-			// create a new branch
-			cmdQueue = append(cmdQueue, []string{"git", "fetch", baseRemote.Name, fmt.Sprintf("%s:%s", ref, newBranchName)})
-			cmdQueue = append(cmdQueue, []string{"git", "checkout", newBranchName})
-		}
-
-		remote := baseRemote.Name
-		mergeRef := ref
-		if pr.MaintainerCanModify {
-			remote = fmt.Sprintf("https://github.com/%s/%s.git", pr.HeadRepositoryOwner.Login, pr.HeadRepository.Name)
-			mergeRef = fmt.Sprintf("refs/heads/%s", pr.HeadRefName)
-		}
-		if mc, err := git.Config(fmt.Sprintf("branch.%s.merge", newBranchName)); err != nil || mc == "" {
-			cmdQueue = append(cmdQueue, []string{"git", "config", fmt.Sprintf("branch.%s.remote", newBranchName), remote})
-			cmdQueue = append(cmdQueue, []string{"git", "config", fmt.Sprintf("branch.%s.merge", newBranchName), mergeRef})
-		}
-	}
-
-	for _, args := range cmdQueue {
-		cmd := exec.Command(args[0], args[1:]...)
-		cmd.Stdout = os.Stdout
-		cmd.Stderr = os.Stderr
-		if err := utils.PrepareCmd(cmd).Run(); err != nil {
-			return err
-		}
-	}
-
-	return nil
-}
-
 func printPrs(w io.Writer, totalCount int, prs ...api.PullRequest) {
 	for _, pr := range prs {
 		prNumber := fmt.Sprintf("#%d", pr.Number)
diff --git a/command/pr_checkout.go b/command/pr_checkout.go
new file mode 100644
index 00000000000..0c41dc793eb
--- /dev/null
+++ b/command/pr_checkout.go
@@ -0,0 +1,114 @@
+package command
+
+import (
+	"errors"
+	"fmt"
+	"os"
+	"os/exec"
+
+	"github.com/cli/cli/git"
+	"github.com/cli/cli/utils"
+	"github.com/spf13/cobra"
+)
+
+func prCheckout(cmd *cobra.Command, args []string) error {
+	ctx := contextForCommand(cmd)
+	currentBranch, _ := ctx.Branch()
+	remotes, err := ctx.Remotes()
+	if err != nil {
+		return err
+	}
+	// FIXME: duplicates logic from fsContext.BaseRepo
+	baseRemote, err := remotes.FindByName("upstream", "github", "origin", "*")
+	if err != nil {
+		return err
+	}
+	apiClient, err := apiClientForContext(ctx)
+	if err != nil {
+		return err
+	}
+
+	pr, err := prFromArg(apiClient, baseRemote, args[0])
+	if err != nil {
+		return err
+	}
+
+	headRemote := baseRemote
+	if pr.IsCrossRepository {
+		headRemote, _ = remotes.FindByRepo(pr.HeadRepositoryOwner.Login, pr.HeadRepository.Name)
+	}
+
+	cmdQueue := [][]string{}
+
+	// namespace PR checkout branches to avoid local branch name collisions
+	newBranchName := fmt.Sprintf("pr/%d/%s", pr.Number, pr.HeadRefName)
+	if headRemote != nil {
+		// there is an existing git remote for PR head
+		remoteBranch := fmt.Sprintf("%s/%s", headRemote.Name, pr.HeadRefName)
+		refSpec := fmt.Sprintf("+refs/heads/%s:refs/remotes/%s", pr.HeadRefName, remoteBranch)
+
+		cmdQueue = append(cmdQueue, []string{"git", "fetch", headRemote.Name, refSpec})
+
+		// local branch already exists
+		if git.VerifyRef("refs/heads/" + newBranchName) {
+			cmdQueue = append(cmdQueue, []string{"git", "checkout", newBranchName})
+			cmdQueue = append(cmdQueue, []string{"git", "merge", "--ff-only", fmt.Sprintf("refs/remotes/%s", remoteBranch)})
+		} else {
+			cmdQueue = append(cmdQueue, []string{"git", "checkout", "-b", newBranchName, "--no-track", remoteBranch})
+			cmdQueue = append(cmdQueue, []string{"git", "config", fmt.Sprintf("branch.%s.remote", newBranchName), headRemote.Name})
+			cmdQueue = append(cmdQueue, []string{"git", "config", fmt.Sprintf("branch.%s.merge", newBranchName), "refs/heads/" + pr.HeadRefName})
+		}
+	} else {
+		// no git remote for PR head
+
+		// avoid naming the new branch the same as the default branch
+		if newBranchName == pr.HeadRepository.DefaultBranchRef.Name {
+			newBranchName = fmt.Sprintf("%s/%s", pr.HeadRepositoryOwner.Login, newBranchName)
+		}
+
+		ref := fmt.Sprintf("refs/pull/%d/head", pr.Number)
+		if newBranchName == currentBranch {
+			// PR head matches currently checked out branch
+			cmdQueue = append(cmdQueue, []string{"git", "fetch", baseRemote.Name, ref})
+			cmdQueue = append(cmdQueue, []string{"git", "merge", "--ff-only", "FETCH_HEAD"})
+		} else {
+			// create a new branch
+			cmdQueue = append(cmdQueue, []string{"git", "fetch", baseRemote.Name, fmt.Sprintf("%s:%s", ref, newBranchName)})
+			cmdQueue = append(cmdQueue, []string{"git", "checkout", newBranchName})
+		}
+
+		remote := baseRemote.Name
+		mergeRef := ref
+		if pr.MaintainerCanModify {
+			remote = fmt.Sprintf("https://github.com/%s/%s.git", pr.HeadRepositoryOwner.Login, pr.HeadRepository.Name)
+			mergeRef = fmt.Sprintf("refs/heads/%s", pr.HeadRefName)
+		}
+		if mc, err := git.Config(fmt.Sprintf("branch.%s.merge", newBranchName)); err != nil || mc == "" {
+			cmdQueue = append(cmdQueue, []string{"git", "config", fmt.Sprintf("branch.%s.remote", newBranchName), remote})
+			cmdQueue = append(cmdQueue, []string{"git", "config", fmt.Sprintf("branch.%s.merge", newBranchName), mergeRef})
+		}
+	}
+
+	for _, args := range cmdQueue {
+		cmd := exec.Command(args[0], args[1:]...)
+		cmd.Stdout = os.Stdout
+		cmd.Stderr = os.Stderr
+		if err := utils.PrepareCmd(cmd).Run(); err != nil {
+			return err
+		}
+	}
+
+	return nil
+}
+
+var prCheckoutCmd = &cobra.Command{
+	Use:   "checkout {<number> | <url> | <branch>}",
+	Short: "Check out a pull request in Git",
+	Args: func(cmd *cobra.Command, args []string) error {
+		if len(args) < 1 {
+			return errors.New("requires a PR number as an argument")
+		}
+		return nil
+	},
+	RunE: prCheckout,
+}

diff --git a/command/pr_checkout_test.go b/command/pr_checkout_test.go
index ba0ddff2291..9500d45304c 100644
--- a/command/pr_checkout_test.go
+++ b/command/pr_checkout_test.go
@@ -42,7 +42,7 @@ func TestPRCheckout_sameRepo(t *testing.T) {
 	ranCommands := [][]string{}
 	restoreCmd := utils.SetPrepareCmd(func(cmd *exec.Cmd) utils.Runnable {
 		switch strings.Join(cmd.Args, " ") {
-		case "git show-ref --verify --quiet refs/heads/feature":
+		case "git show-ref --verify --quiet refs/heads/pr/123/feature":
 			return &errorStub{"exit status: 1"}
 		default:
 			ranCommands = append(ranCommands, cmd.Args)
@@ -57,9 +57,9 @@ func TestPRCheckout_sameRepo(t *testing.T) {
 
 	eq(t, len(ranCommands), 4)
 	eq(t, strings.Join(ranCommands[0], " "), "git fetch origin +refs/heads/feature:refs/remotes/origin/feature")
-	eq(t, strings.Join(ranCommands[1], " "), "git checkout -b feature --no-track origin/feature")
-	eq(t, strings.Join(ranCommands[2], " "), "git config branch.feature.remote origin")
-	eq(t, strings.Join(ranCommands[3], " "), "git config branch.feature.merge refs/heads/feature")
+	eq(t, strings.Join(ranCommands[1], " "), "git checkout -b pr/123/feature --no-track origin/feature")
+	eq(t, strings.Join(ranCommands[2], " "), "git config branch.pr/123/feature.remote origin")
+	eq(t, strings.Join(ranCommands[3], " "), "git config branch.pr/123/feature.merge refs/heads/feature")
 }
 
 func TestPRCheckout_urlArg(t *testing.T) {
@@ -94,7 +94,7 @@ func TestPRCheckout_urlArg(t *testing.T) {
 	ranCommands := [][]string{}
 	restoreCmd := utils.SetPrepareCmd(func(cmd *exec.Cmd) utils.Runnable {
 		switch strings.Join(cmd.Args, " ") {
-		case "git show-ref --verify --quiet refs/heads/feature":
+		case "git show-ref --verify --quiet refs/heads/pr/123/feature":
 			return &errorStub{"exit status: 1"}
 		default:
 			ranCommands = append(ranCommands, cmd.Args)
@@ -108,7 +108,7 @@ func TestPRCheckout_urlArg(t *testing.T) {
 	eq(t, output.String(), "")
 
 	eq(t, len(ranCommands), 4)
-	eq(t, strings.Join(ranCommands[1], " "), "git checkout -b feature --no-track origin/feature")
+	eq(t, strings.Join(ranCommands[1], " "), "git checkout -b pr/123/feature --no-track origin/feature")
 }
 
 func TestPRCheckout_branchArg(t *testing.T) {
@@ -143,7 +143,7 @@ func TestPRCheckout_branchArg(t *testing.T) {
 	ranCommands := [][]string{}
 	restoreCmd := utils.SetPrepareCmd(func(cmd *exec.Cmd) utils.Runnable {
 		switch strings.Join(cmd.Args, " ") {
-		case "git show-ref --verify --quiet refs/heads/feature":
+		case "git show-ref --verify --quiet refs/heads/pr/123/feature":
 			return &errorStub{"exit status: 1"}
 		default:
 			ranCommands = append(ranCommands, cmd.Args)
@@ -157,7 +157,7 @@ func TestPRCheckout_branchArg(t *testing.T) {
 	eq(t, output.String(), "")
 
 	eq(t, len(ranCommands), 5)
-	eq(t, strings.Join(ranCommands[1], " "), "git fetch origin refs/pull/123/head:feature")
+	eq(t, strings.Join(ranCommands[1], " "), "git fetch origin refs/pull/123/head:pr/123/feature")
 }
 
 func TestPRCheckout_existingBranch(t *testing.T) {
@@ -192,7 +192,7 @@ func TestPRCheckout_existingBranch(t *testing.T) {
 	ranCommands := [][]string{}
 	restoreCmd := utils.SetPrepareCmd(func(cmd *exec.Cmd) utils.Runnable {
 		switch strings.Join(cmd.Args, " ") {
-		case "git show-ref --verify --quiet refs/heads/feature":
+		case "git show-ref --verify --quiet refs/heads/pr/123/feature":
 			return &outputStub{}
 		default:
 			ranCommands = append(ranCommands, cmd.Args)
@@ -207,7 +207,7 @@ func TestPRCheckout_existingBranch(t *testing.T) {
 
 	eq(t, len(ranCommands), 3)
 	eq(t, strings.Join(ranCommands[0], " "), "git fetch origin +refs/heads/feature:refs/remotes/origin/feature")
-	eq(t, strings.Join(ranCommands[1], " "), "git checkout feature")
+	eq(t, strings.Join(ranCommands[1], " "), "git checkout pr/123/feature")
 	eq(t, strings.Join(ranCommands[2], " "), "git merge --ff-only refs/remotes/origin/feature")
 }
 
@@ -244,7 +244,7 @@ func TestPRCheckout_differentRepo_remoteExists(t *testing.T) {
 	ranCommands := [][]string{}
 	restoreCmd := utils.SetPrepareCmd(func(cmd *exec.Cmd) utils.Runnable {
 		switch strings.Join(cmd.Args, " ") {
-		case "git show-ref --verify --quiet refs/heads/feature":
+		case "git show-ref --verify --quiet refs/heads/pr/123/feature":
 			return &errorStub{"exit status: 1"}
 		default:
 			ranCommands = append(ranCommands, cmd.Args)
@@ -259,9 +259,9 @@ func TestPRCheckout_differentRepo_remoteExists(t *testing.T) {
 
 	eq(t, len(ranCommands), 4)
 	eq(t, strings.Join(ranCommands[0], " "), "git fetch robot-fork +refs/heads/feature:refs/remotes/robot-fork/feature")
-	eq(t, strings.Join(ranCommands[1], " "), "git checkout -b feature --no-track robot-fork/feature")
-	eq(t, strings.Join(ranCommands[2], " "), "git config branch.feature.remote robot-fork")
-	eq(t, strings.Join(ranCommands[3], " "), "git config branch.feature.merge refs/heads/feature")
+	eq(t, strings.Join(ranCommands[1], " "), "git checkout -b pr/123/feature --no-track robot-fork/feature")
+	eq(t, strings.Join(ranCommands[2], " "), "git config branch.pr/123/feature.remote robot-fork")
+	eq(t, strings.Join(ranCommands[3], " "), "git config branch.pr/123/feature.merge refs/heads/feature")
 }
 
 func TestPRCheckout_differentRepo(t *testing.T) {
@@ -296,7 +296,7 @@ func TestPRCheckout_differentRepo(t *testing.T) {
 	ranCommands := [][]string{}
 	restoreCmd := utils.SetPrepareCmd(func(cmd *exec.Cmd) utils.Runnable {
 		switch strings.Join(cmd.Args, " ") {
-		case "git config branch.feature.merge":
+		case "git config branch.pr/123/feature.merge":
 			return &errorStub{"exit status 1"}
 		default:
 			ranCommands = append(ranCommands, cmd.Args)
@@ -310,10 +310,10 @@ func TestPRCheckout_differentRepo(t *testing.T) {
 	eq(t, output.String(), "")
 
 	eq(t, len(ranCommands), 4)
-	eq(t, strings.Join(ranCommands[0], " "), "git fetch origin refs/pull/123/head:feature")
-	eq(t, strings.Join(ranCommands[1], " "), "git checkout feature")
-	eq(t, strings.Join(ranCommands[2], " "), "git config branch.feature.remote origin")
-	eq(t, strings.Join(ranCommands[3], " "), "git config branch.feature.merge refs/pull/123/head")
+	eq(t, strings.Join(ranCommands[0], " "), "git fetch origin refs/pull/123/head:pr/123/feature")
+	eq(t, strings.Join(ranCommands[1], " "), "git checkout pr/123/feature")
+	eq(t, strings.Join(ranCommands[2], " "), "git config branch.pr/123/feature.remote origin")
+	eq(t, strings.Join(ranCommands[3], " "), "git config branch.pr/123/feature.merge refs/pull/123/head")
 }
 
 func TestPRCheckout_differentRepo_existingBranch(t *testing.T) {
@@ -348,7 +348,7 @@ func TestPRCheckout_differentRepo_existingBranch(t *testing.T) {
 	ranCommands := [][]string{}
 	restoreCmd := utils.SetPrepareCmd(func(cmd *exec.Cmd) utils.Runnable {
 		switch strings.Join(cmd.Args, " ") {
-		case "git config branch.feature.merge":
+		case "git config branch.pr/123/feature.merge":
 			return &outputStub{[]byte("refs/heads/feature\n")}
 		default:
 			ranCommands = append(ranCommands, cmd.Args)
@@ -362,13 +362,13 @@ func TestPRCheckout_differentRepo_existingBranch(t *testing.T) {
 	eq(t, output.String(), "")
 
 	eq(t, len(ranCommands), 2)
-	eq(t, strings.Join(ranCommands[0], " "), "git fetch origin refs/pull/123/head:feature")
-	eq(t, strings.Join(ranCommands[1], " "), "git checkout feature")
+	eq(t, strings.Join(ranCommands[0], " "), "git fetch origin refs/pull/123/head:pr/123/feature")
+	eq(t, strings.Join(ranCommands[1], " "), "git checkout pr/123/feature")
 }
 
 func TestPRCheckout_differentRepo_currentBranch(t *testing.T) {
 	ctx := context.NewBlank()
-	ctx.SetBranch("feature")
+	ctx.SetBranch("pr/123/feature")
 	ctx.SetRemotes(map[string]string{
 		"origin": "OWNER/REPO",
 	})
@@ -398,7 +398,7 @@ func TestPRCheckout_differentRepo_currentBranch(t *testing.T) {
 	ranCommands := [][]string{}
 	restoreCmd := utils.SetPrepareCmd(func(cmd *exec.Cmd) utils.Runnable {
 		switch strings.Join(cmd.Args, " ") {
-		case "git config branch.feature.merge":
+		case "git config branch.pr/123/feature.merge":
 			return &outputStub{[]byte("refs/heads/feature\n")}
 		default:
 			ranCommands = append(ranCommands, cmd.Args)
@@ -448,7 +448,7 @@ func TestPRCheckout_maintainerCanModify(t *testing.T) {
 	ranCommands := [][]string{}
 	restoreCmd := utils.SetPrepareCmd(func(cmd *exec.Cmd) utils.Runnable {
 		switch strings.Join(cmd.Args, " ") {
-		case "git config branch.feature.merge":
+		case "git config branch.pr/123/feature.merge":
 			return &errorStub{"exit status 1"}
 		default:
 			ranCommands = append(ranCommands, cmd.Args)
@@ -462,8 +462,8 @@ func TestPRCheckout_maintainerCanModify(t *testing.T) {
 	eq(t, output.String(), "")
 
 	eq(t, len(ranCommands), 4)
-	eq(t, strings.Join(ranCommands[0], " "), "git fetch origin refs/pull/123/head:feature")
-	eq(t, strings.Join(ranCommands[1], " "), "git checkout feature")
-	eq(t, strings.Join(ranCommands[2], " "), "git config branch.feature.remote https://github.com/hubot/REPO.git")
-	eq(t, strings.Join(ranCommands[3], " "), "git config branch.feature.merge refs/heads/feature")
+	eq(t, strings.Join(ranCommands[0], " "), "git fetch origin refs/pull/123/head:pr/123/feature")
+	eq(t, strings.Join(ranCommands[1], " "), "git checkout pr/123/feature")
+	eq(t, strings.Join(ranCommands[2], " "), "git config branch.pr/123/feature.remote https://github.com/hubot/REPO.git")
+	eq(t, strings.Join(ranCommands[3], " "), "git config branch.pr/123/feature.merge refs/heads/feature")
 }

{"TestPRCheckout_differentRepo_existingBranch": {"run": "PASS", "test": "FAIL", "fix": "PASS"}, "TestPRCheckout_differentRepo_remoteExists": {"run": "PASS", "test": "FAIL", "fix": "PASS"}, "TestPRCheckout_urlArg": {"run": "PASS", "test": "FAIL", "fix": "PASS"}, "TestPRCheckout_existingBranch": {"run": "PASS", "test": "FAIL", "fix": "PASS"}, "TestPRCheckout_sameRepo": {"run": "PASS", "test": "FAIL", "fix": "PASS"}, "TestPRCheckout_differentRepo_currentBranch": {"run": "PASS", "test": "FAIL", "fix": "PASS"}, "TestPRCheckout_maintainerCanModify": {"run": "PASS", "test": "FAIL", "fix": "PASS"}, "TestPRCheckout_branchArg": {"run": "PASS", "test": "FAIL", "fix": "PASS"}, "TestPRCheckout_differentRepo": {"run": "PASS", "test": "FAIL", "fix": "PASS"}}
{"TestExtractName/Incomplete_front-matter": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPullRequest_ChecksStatus": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestIssueView_preview": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRView_urlArg": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestCompletion_fish": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRView_branchArg": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestReplaceExcessiveWhitespace": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "Test_sshParse": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestCheckForUpdate/current_is_prerelease": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestFind/Multiple_templates": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "Test_resolvedRemotes_triangularSetup": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestFind": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestGitStatusHelperProcess": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRStatus_reviewsAndChecks": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestChangelogURL": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestIssueStatus_disabledIssues": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestIssueCreate": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestCheckForUpdate": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestIssueView": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestGraphQLError": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRView_previewCurrentBranch": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestFind/Empty_multiple_templates_directory": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestExtractName": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestGraphQL": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRStatus_blankSlate": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestForOS/Windows": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRView_branchWithOwnerArg": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestFuzzyAgo": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestCompletion_bash": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestExtractName/No_front-matter": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRList": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "Test_printError/Cobra_flag_error": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestCompletion_zsh": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestForOS": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRCreate_ReportsUncommittedChanges": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestExtractName/Complete_front-matter": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "Test_UncommittedChangeCount": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestIssueView_urlArg": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "Test_printError/DNS_error": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestIssueStatus": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestFind/Template_in_docs": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestIssueCreate_web": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestExtractContents": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestFind/Template_in_.github_takes_precedence": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "Test_printError/generic_error": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestIssueCreate_disabledIssues": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestFind/Template_in_root": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestCompletion_unsupported": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRCreate": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestIssueList_disabledIssues": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "Test_Translator": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRList_filteringAssignee": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRList_filteringAssigneeLabels": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRView_currentBranch": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestIssueList_withFlags": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestExtractContents/Has_front-matter": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestExtractContents/No_front-matter": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestCheckForUpdate/latest_is_older": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRView_preview": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestIssueList": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestIssueView_disabledIssues": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestCheckForUpdate/latest_is_current": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRView_numberArg": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRView_noResultsForBranch": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "Test_printError": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRCreate_web": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRStatus": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "Test_printError/unknown_Cobra_command_error": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPrCreateHelperProcess": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestForOS/macOS": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestForOS/Linux": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "Test_repoFromURL": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "Test_parseRemotes": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestIssueView_notFound": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestPRList_filtering": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestIssueStatus_blankSlate": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestIssueList_nullAssigneeLabels": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "Test_resolvedRemotes_clonedFork": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "TestCheckForUpdate/latest_is_newer": {"run": "PASS", "test": "PASS", "fix": "PASS"}, "Test_repoFromURL_invalid": {"run": "PASS", "test": "PASS", "fix": "PASS"}}
{"TestPRCheckout_differentRepo_existingBranch": {"run": "PASS", "test": "FAIL", "fix": "PASS"}, "TestPRCheckout_differentRepo_remoteExists": {"run": "PASS", "test": "FAIL", "fix": "PASS"}, "TestPRCheckout_urlArg": {"run": "PASS", "test": "FAIL", "fix": "PASS"}, "TestPRCheckout_existingBranch": {"run": "PASS", "test": "FAIL", "fix": "PASS"}, "TestPRCheckout_sameRepo": {"run": "PASS", "test": "FAIL", "fix": "PASS"}, "TestPRCheckout_differentRepo_currentBranch": {"run": "PASS", "test": "FAIL", "fix": "PASS"}, "TestPRCheckout_maintainerCanModify": {"run": "PASS", "test": "FAIL", "fix": "PASS"}, "TestPRCheckout_branchArg": {"run": "PASS", "test": "FAIL", "fix": "PASS"}, "TestPRCheckout_differentRepo": {"run": "PASS", "test": "FAIL", "fix": "PASS"}}
{"passed_count": 89, "failed_count": 1, "skipped_count": 0, "passed_tests": ["TestExtractName/Incomplete_front-matter", "TestPullRequest_ChecksStatus", "TestPRView_urlArg", "TestCompletion_fish", "TestPRView_branchArg", "TestReplaceExcessiveWhitespace", "TestFind/Multiple_templates", "Test_resolvedRemotes_triangularSetup", "TestFind", "TestPRStatus_reviewsAndChecks", "TestChangelogURL", "TestCheckForUpdate", "TestPRView_previewCurrentBranch", "TestGraphQL", "TestPRStatus_blankSlate", "TestPRView_branchWithOwnerArg", "TestCompletion_bash", "TestExtractName/No_front-matter", "Test_printError/Cobra_flag_error", "TestCompletion_zsh", "TestForOS", "Test_UncommittedChangeCount", "Test_printError/DNS_error", "TestIssueStatus", "TestFind/Template_in_docs", "TestExtractContents", "TestFind/Template_in_.github_takes_precedence", "Test_printError/generic_error", "TestPRCheckout_sameRepo", "TestIssueList_disabledIssues", "TestPRList_filteringAssigneeLabels", "TestPRView_currentBranch", "TestIssueList_withFlags", "TestExtractContents/Has_front-matter", "TestPRView_preview", "TestIssueView_disabledIssues", "TestCheckForUpdate/latest_is_current", "TestPRCreate_web", "TestPRCheckout_branchArg", "TestPRCheckout_differentRepo", "TestPRList_filtering", "Test_resolvedRemotes_clonedFork", "Test_repoFromURL_invalid", "TestIssueView_preview", "TestPRCheckout_differentRepo_existingBranch", "Test_sshParse", "TestCheckForUpdate/current_is_prerelease", "TestGitStatusHelperProcess", "TestIssueStatus_disabledIssues", "TestIssueCreate", "TestIssueView", "TestGraphQLError", "TestFind/Empty_multiple_templates_directory", "TestExtractName", "TestForOS/Windows", "TestFuzzyAgo", "TestPRList", "TestPRCheckout_differentRepo_remoteExists", "TestPRCreate_ReportsUncommittedChanges", "TestExtractName/Complete_front-matter", "TestPRCheckout_urlArg", "TestIssueView_urlArg", "TestIssueCreate_web", "TestPRCheckout_existingBranch", "TestIssueCreate_disabledIssues", "TestFind/Template_in_root", "TestCompletion_unsupported", "TestPRCreate", "Test_Translator", "TestPRList_filteringAssignee", "TestExtractContents/No_front-matter", "TestPRCheckout_differentRepo_currentBranch", "TestCheckForUpdate/latest_is_older", "TestIssueList", "TestPRCheckout_maintainerCanModify", "TestPRView_numberArg", "TestPRView_noResultsForBranch", "Test_printError", "TestPRStatus", "Test_printError/unknown_Cobra_command_error", "TestPrCreateHelperProcess", "TestForOS/macOS", "TestForOS/Linux", "Test_repoFromURL", "Test_parseRemotes", "TestIssueView_notFound", "TestIssueStatus_blankSlate", "TestIssueList_nullAssigneeLabels", "TestCheckForUpdate/latest_is_newer"], "failed_tests": ["github.com/cli/cli/context"], "skipped_tests": []}
{"passed_count": 80, "failed_count": 11, "skipped_count": 0, "passed_tests": ["TestExtractName/Incomplete_front-matter", "TestPullRequest_ChecksStatus", "TestPRView_urlArg", "TestCompletion_fish", "TestPRView_branchArg", "TestReplaceExcessiveWhitespace", "TestFind/Multiple_templates", "Test_resolvedRemotes_triangularSetup", "TestFind", "TestPRStatus_reviewsAndChecks", "TestChangelogURL", "TestCheckForUpdate", "TestPRView_previewCurrentBranch", "TestGraphQL", "TestPRStatus_blankSlate", "TestPRView_branchWithOwnerArg", "TestCompletion_bash", "TestExtractName/No_front-matter", "Test_printError/Cobra_flag_error", "TestCompletion_zsh", "TestForOS", "Test_UncommittedChangeCount", "Test_printError/DNS_error", "TestIssueStatus", "TestFind/Template_in_docs", "TestExtractContents", "TestFind/Template_in_.github_takes_precedence", "Test_printError/generic_error", "TestIssueList_disabledIssues", "TestPRList_filteringAssigneeLabels", "TestPRView_currentBranch", "TestIssueList_withFlags", "TestExtractContents/Has_front-matter", "TestPRView_preview", "TestIssueView_disabledIssues", "TestCheckForUpdate/latest_is_current", "TestPRCreate_web", "TestPRList_filtering", "Test_resolvedRemotes_clonedFork", "Test_repoFromURL_invalid", "TestIssueView_preview", "Test_sshParse", "TestCheckForUpdate/current_is_prerelease", "TestGitStatusHelperProcess", "TestIssueStatus_disabledIssues", "TestIssueCreate", "TestIssueView", "TestGraphQLError", "TestFind/Empty_multiple_templates_directory", "TestExtractName", "TestForOS/Windows", "TestFuzzyAgo", "TestPRList", "TestPRCreate_ReportsUncommittedChanges", "TestExtractName/Complete_front-matter", "TestIssueView_urlArg", "TestIssueCreate_web", "TestIssueCreate_disabledIssues", "TestFind/Template_in_root", "TestCompletion_unsupported", "TestPRCreate", "Test_Translator", "TestPRList_filteringAssignee", "TestExtractContents/No_front-matter", "TestCheckForUpdate/latest_is_older", "TestIssueList", "TestPRView_numberArg", "TestPRView_noResultsForBranch", "Test_printError", "TestPRStatus", "Test_printError/unknown_Cobra_command_error", "TestPrCreateHelperProcess", "TestForOS/macOS", "TestForOS/Linux", "Test_repoFromURL", "Test_parseRemotes", "TestIssueView_notFound", "TestIssueStatus_blankSlate", "TestIssueList_nullAssigneeLabels", "TestCheckForUpdate/latest_is_newer"], "failed_tests": ["TestPRCheckout_urlArg", "TestPRCheckout_sameRepo", "TestPRCheckout_branchArg", "TestPRCheckout_maintainerCanModify", "TestPRCheckout_differentRepo", "github.com/cli/cli/context", "github.com/cli/cli/command", "TestPRCheckout_differentRepo_existingBranch", "TestPRCheckout_differentRepo_currentBranch", "TestPRCheckout_existingBranch", "TestPRCheckout_differentRepo_remoteExists"], "skipped_tests": []}
{"passed_count": 89, "failed_count": 1, "skipped_count": 0, "passed_tests": ["TestExtractName/Incomplete_front-matter", "TestPullRequest_ChecksStatus", "TestPRView_urlArg", "TestCompletion_fish", "TestPRView_branchArg", "TestReplaceExcessiveWhitespace", "TestFind/Multiple_templates", "Test_resolvedRemotes_triangularSetup", "TestFind", "TestPRStatus_reviewsAndChecks", "TestChangelogURL", "TestCheckForUpdate", "TestPRView_previewCurrentBranch", "TestGraphQL", "TestPRStatus_blankSlate", "TestPRView_branchWithOwnerArg", "TestCompletion_bash", "TestExtractName/No_front-matter", "Test_printError/Cobra_flag_error", "TestCompletion_zsh", "TestForOS", "Test_UncommittedChangeCount", "Test_printError/DNS_error", "TestIssueStatus", "TestFind/Template_in_docs", "TestExtractContents", "TestFind/Template_in_.github_takes_precedence", "Test_printError/generic_error", "TestPRCheckout_sameRepo", "TestIssueList_disabledIssues", "TestPRList_filteringAssigneeLabels", "TestPRView_currentBranch", "TestIssueList_withFlags", "TestExtractContents/Has_front-matter", "TestPRView_preview", "TestIssueView_disabledIssues", "TestCheckForUpdate/latest_is_current", "TestPRCreate_web", "TestPRCheckout_branchArg", "TestPRCheckout_differentRepo", "TestPRList_filtering", "Test_resolvedRemotes_clonedFork", "Test_repoFromURL_invalid", "TestIssueView_preview", "TestPRCheckout_differentRepo_existingBranch", "Test_sshParse", "TestCheckForUpdate/current_is_prerelease", "TestGitStatusHelperProcess", "TestIssueStatus_disabledIssues", "TestIssueCreate", "TestIssueView", "TestGraphQLError", "TestFind/Empty_multiple_templates_directory", "TestExtractName", "TestForOS/Windows", "TestFuzzyAgo", "TestPRList", "TestPRCheckout_differentRepo_remoteExists", "TestPRCreate_ReportsUncommittedChanges", "TestExtractName/Complete_front-matter", "TestPRCheckout_urlArg", "TestIssueView_urlArg", "TestIssueCreate_web", "TestPRCheckout_existingBranch", "TestIssueCreate_disabledIssues", "TestFind/Template_in_root", "TestCompletion_unsupported", "TestPRCreate", "Test_Translator", "TestPRList_filteringAssignee", "TestExtractContents/No_front-matter", "TestPRCheckout_differentRepo_currentBranch", "TestCheckForUpdate/latest_is_older", "TestIssueList", "TestPRCheckout_maintainerCanModify", "TestPRView_numberArg", "TestPRView_noResultsForBranch", "Test_printError", "TestPRStatus", "Test_printError/unknown_Cobra_command_error", "TestPrCreateHelperProcess", "TestForOS/macOS", "TestForOS/Linux", "Test_repoFromURL", "Test_parseRemotes", "TestIssueView_notFound", "TestIssueStatus_blankSlate", "TestIssueList_nullAssigneeLabels", "TestCheckForUpdate/latest_is_newer"], "failed_tests": ["github.com/cli/cli/context"], "skipped_tests": []}