resolve PR review
This commit is contained in:
parent
3bb6983b35
commit
fb7b01b40c
4 changed files with 36 additions and 7 deletions
|
|
@ -116,7 +116,7 @@ func prStatus(cmd *cobra.Command, args []string) error {
|
|||
repoOverride, _ := cmd.Flags().GetString("repo")
|
||||
currentPRNumber, currentPRHeadRef, err := prSelectorForCurrentBranch(ctx, baseRepo)
|
||||
|
||||
if err != nil && repoOverride == "" && err != git.ErrNotOnAnyBranch {
|
||||
if err != nil && repoOverride == "" && !errors.Is(err, git.ErrNotOnAnyBranch) {
|
||||
return fmt.Errorf("could not query for pull request for current branch: %w", err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -299,6 +299,38 @@ Requesting a code review from you
|
|||
}
|
||||
}
|
||||
|
||||
func TestPRStatus_detachedHead(t *testing.T) {
|
||||
initBlankContext("", "OWNER/REPO", "")
|
||||
http := initFakeHTTP()
|
||||
http.StubRepoResponse("OWNER", "REPO")
|
||||
|
||||
http.StubResponse(200, bytes.NewBufferString(`
|
||||
{ "data": {} }
|
||||
`))
|
||||
|
||||
output, err := RunCommand("pr status")
|
||||
if err != nil {
|
||||
t.Errorf("error running command `pr status`: %v", err)
|
||||
}
|
||||
|
||||
expected := `
|
||||
Relevant pull requests in OWNER/REPO
|
||||
|
||||
Current branch
|
||||
There is no current branch
|
||||
|
||||
Created by you
|
||||
You have no open pull requests
|
||||
|
||||
Requesting a code review from you
|
||||
You have no pull requests to review
|
||||
|
||||
`
|
||||
if output.String() != expected {
|
||||
t.Errorf("expected %q, got %q", expected, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestPRList(t *testing.T) {
|
||||
initBlankContext("", "OWNER/REPO", "master")
|
||||
http := initFakeHTTP()
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ func NewBlank() *blankContext {
|
|||
type blankContext struct {
|
||||
authToken string
|
||||
branch string
|
||||
branchErr error
|
||||
baseRepo ghrepo.Interface
|
||||
remotes Remotes
|
||||
}
|
||||
|
|
@ -40,7 +41,7 @@ func (c *blankContext) SetAuthToken(t string) {
|
|||
|
||||
func (c *blankContext) Branch() (string, error) {
|
||||
if c.branch == "" {
|
||||
return "", fmt.Errorf("branch was not initialized")
|
||||
return "", fmt.Errorf("branch was not initialized: %w", git.ErrNotOnAnyBranch)
|
||||
}
|
||||
return c.branch, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,11 +207,7 @@ func (c *fsContext) Branch() (string, error) {
|
|||
}
|
||||
|
||||
currentBranch, err := git.CurrentBranch()
|
||||
switch err {
|
||||
case nil:
|
||||
case git.ErrNotOnAnyBranch:
|
||||
return "", err
|
||||
default:
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not determine current branch: %w", err)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue