This ensures that checking for newer versions of gh happens in the background of the main operation that the user requested, and that when that operation is completed, the gh process should immediately exit without being delayed by the update checker goroutine.
This will check if `gh` is running in a CI environment. If so, it will
suggest using environment variables to set the auth token. Additionally,
if the CI environment is detected to be GitHub Actions, it will provide
some example code. If it is not a CI environment, it will print the
standard help message.
Co-authored-by: Mislav Marohnić <mislav@github.com>
We can strip the "v" prefix where it's unambiguous that we're talking
about version numbers.
Before:
A new release of gh is available: 2.8.0 => v2.9.0
After:
A new release of gh is available: 2.8.0 => 2.9.0
The GH_DEBUG environment variable is a new gh-specific verbosity control.
For backwards-compatibility, DEBUG will still be respected if it has values
"1", "true", "yes", and "api", but any other values will be ignored.
Finally, support for "oauth" debug value has been dropped in favor of "api".
The "oauth" value only had limited, internal use.
Co-authored-by: Mislav Marohnić <mislav@github.com>
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.