fix: correctly set ErrNotOnAnyBranch error in git client (#7082)

Before, git client was not correctly setting `ErrNotOnAnyBranch` error.
Because of that, `gh pr status` was not functioning correctly when run
from the detached HEAD. This commit fixes that.

Fixes #7051
This commit is contained in:
Alex Petrov 2023-03-05 17:16:29 -05:00 committed by GitHub
parent 2268d2e4eb
commit 7d4ab65af3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -142,6 +142,7 @@ func (c *Client) CurrentBranch(ctx context.Context) (string, error) {
if err != nil {
var gitErr *GitError
if ok := errors.As(err, &gitErr); ok && len(gitErr.Stderr) == 0 {
gitErr.err = ErrNotOnAnyBranch
gitErr.Stderr = "not on any branch"
return "", gitErr
}