While a gh command is writing stdout to a pager, the user may choose to
close the pager program before the pager has read all the data on its
standard input. In that case, the parent gh process will receive an
EPIPE error, which would bubble up its error handling and cause it to
print something like:
write |1: broken pipe
Since this was caused by an explicit user action of closing the pager,
and since the user probably doesn't want to see this uninformative
error, this informs our global error handling of this error and causes
it to be ignored.
Whenever a SSO challenge gets issued by the server by means of a URL in
the `X-GitHub-SSO` response header, gh now additionally prints that URL
on the standard error stream.
This is achieved by installing a middleware to all HTTP requests and
storing the server challenge to a value accessible by `factory.SSOURL()`.
Such approach was made necessary mainly because of the
`shurcool-graphql` client which doesn't give access to response headers
when a GraphQL error case is encountered.
If a 4xx server response lists scopes in the X-Accepted-Oauth-Scopes
header that are not present in the X-Oauth-Scopes header, the final
error messaging on stderr will now include a hint for the user that they
might need to request the additional scope:
$ gh codespace list
error getting codespaces: HTTP 403: Must have admin rights to Repository. (https://api.github.com/user/codespaces?per_page=30)
This API operation needs the "codespace" scope. To request it, run: gh auth refresh -h github.com -s codespace
This is to avoid hitting the filesystem and resolving symlinks
unnecessarily. The value of executable is just used conditionally by a
handful of commands.
As far as I can put together, this error appears when someone has
authenticated GitHub CLI with a PAT that isn't authorized to access a
certain org. It can also happen if someone has authorized GitHub CLI
using the legacy "GitHub CLI (dev)" OAuth app instead of our production
OAuth app.
Doing `gh auth refresh` will re-authenticate the user using our
production "GitHub CLI" OAuth app which will not have problems accessing
resources in different GitHub organizations.
Replace the implementation that relied on symlinks with the one that
create regular files that act like symlinks: they contain a reference to
the local directory where to find the extension.
- Extensions on Windows now enabled through the `sh.exe` interpreter
- `sh.exe` now found on Windows when git was installed via scoop
- `gh extensions list` command shows origin repo for the extension
- `gh extensions upgrade --all` is required to upgrade all extensions
- Added `gh extensions remove`
- Shell completions now include aliases and extension names
- `gh` help output now lists available extension names
- Extensions are stored to XDG_DATA_HOME
The linter picked up that the error value from cmd.Help() isn't checked.
Even though cmd.Help() returns an error value, it's always nil. The
inner HelpFunc() function directly prints the error message instead of
returning an error value.
If `GH_PAGER` is exists, set it as the pager even if one is
already set in config.
This allows a user to change/disable the pager per single invocation.
PS C:\Users\Junjie Yuan> gh auth status
github.com
✓ Logged in to github.com as junjieyuan (C:\Users\Junjie Yuan\.config\gh/hosts.yml)
✓ Git operations for github.com configured to use https protocol.
✓ Token: *******************
Signed-off-by: Junjie Yuan <yuan@junjie.pro>
Avoid displaying upgrade notice if any output is redirected. This also
alleviates the need to specifically check for `gh completion -s
<shell>`, `gh __complete`, and other scripting scenarios where we
absolutely don't want to trigger any upgrade checks or notices.
Here are the statuses:
- 0: success
- 1: misc. error
- 2: user interrupt/cancellation
- 4: authentication needed
These old exit codes are now changed to "1":
- we used to return "2" for config file errors;
- we used to return "2" for alias expansion errors;
- we used to return "3" for alias runtime errors.
I do not believe that there is a need to distinguish these specific
cases via exit status, and converting them to "1" frees codes "2" and
"3" for more practical use.
Before, when gh detected there was a new release in the `cli/cli` repo,
it would show this notice:
A new release of gh is available: {V1} → {V2}
Additionally, when the release was more than 24h old, we would show this
to Homebrew users:
To upgrade, run: brew update && brew upgrade gh
Ref. feb4acc2c0
This change makes it so that the original notice "A new release of gh is
available" is NOT shown to Homebrew users unless the release is older
than 24h. We effectively hide the fact that any release happened until
we're sure that the version bump has made it to `homebrew-core`.
When the update notifier is enabled and a new version was detected, show
a Homebrew upgrade notice if:
- the release was at least 24 hours ago; and
- the current `gh` binary is under the Homebrew prefix.