Commit graph

381 commits

Author SHA1 Message Date
Mislav Marohnić
82ac154d56 Consistent version format in version upgrade notice
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
2022-05-02 13:29:10 +02:00
Roshan Padaki
7a3d02df47
Add autocomplete descriptions for aliases and extensions (#5447) 2022-04-26 13:08:16 +02:00
Håvard Anda Estensen
58cb773e09
Replace ioutil with io and os (#5498) 2022-04-26 13:07:44 +02:00
Roshan Padaki
13342cb272
Don't error on list commands when no results found (#5479)
Co-authored-by: Mislav Marohnić <mislav@github.com>
2022-04-25 17:55:52 +00:00
Sam Coe
2c0236d096
Add extension upgrade --dry-run (#5098) 2022-04-12 07:18:08 +00:00
lylecantcode
56fda0f8c6
Support GH_DEBUG to control verbosity, deprecate DEBUG (#5306)
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>
2022-03-29 18:05:35 +02:00
Mislav Marohnić
0a5e220231 Ignore EPIPE errors when writing to a closed pager
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.
2022-02-10 16:42:00 +01:00
Audree Steinberg
1ec2c0807e
Add new line after error (#5124)
* Add new line

* Fix syntax for adding new line

* Add `\n` to another error
2022-02-01 08:35:46 +01:00
Mislav Marohnić
66c18b40f2
Handle SAML enforcement challenge from the server (#5054)
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.
2022-01-19 14:22:22 +01:00
Mislav Marohnić
31c7181297 Refresh man pages
- Fix name of man pages for all but the toplevel command
- Set title of all man pages to "GitHub CLI manual"
- Include gh version information in man pages
- Clean up rendering of flags section
- List subcommands for every command
2021-12-20 18:11:31 +01:00
Alan Donovan
f4491c7a80 Add FlagErrorf; encapsulate FlagError.error 2021-10-21 11:40:20 -04:00
Mislav Marohnić
2ca18e0600 Warn about missing OAuth scopes when reporting HTTP 4xx errors
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
2021-10-13 23:24:14 +02:00
Jose Garcia
9e6c11e767 Move cmd/ghcs to pkg/cmd/codespace
- Delete pkg/cmd/codespace/main as it is no longer needed in this
  codebase
2021-09-30 11:20:13 -04:00
Mislav Marohnić
48bac0abd2 Fix race in codespaces delete test 2021-09-29 16:40:40 +02:00
Jose Garcia
a0f11b6664 Handle concurrency in tests and logger
- Live Share tests
- Logger implementation for ghcs
2021-09-29 16:40:40 +02:00
Mislav Marohnić
f749590e87 Replace old "github/ghcs" import statements 2021-09-28 16:57:56 +02:00
Mislav Marohnić
e64607d07b Merge remote-tracking branch 'ghcs/main' into import-codespaces
Co-authored-by: Jose Garcia <josebalius@github.com>
2021-09-28 16:46:27 +02:00
Mislav Marohnić
f947ef3448 Remove lightstep configuration
The `github.com/shirou/gopsutil` dependency of lightstep-tracer is
giving us trouble during building.

Ref. https://github.com/shirou/gopsutil/issues/976

Another build problem raises its head even after we upgrade gopsutil to
a version where the above bug is fixed.
2021-09-28 16:42:35 +02:00
Mislav Marohnić
c82d4c5472 Avoid passing params struct as pointer 2021-09-24 17:36:18 +02:00
Mislav Marohnić
dc8f6ef183 No longer accept a logger in CreateCodespace
The API layer shouldn't concern itself with logging progress to stderr.
Instead, we will subsequently add progress indicators in the caller
around CreateCodespace and other potentially slow commands as needed.
2021-09-24 17:30:31 +02:00
Mislav Marohnić
ca0f89d3bc Introduce an App struct that executes core business logic
The Cobra commands are now a light wrapper around the App struct.

Co-authored-by: Jose Garcia <josebalius@github.com>
2021-09-24 17:20:34 +02:00
Mislav Marohnić
8807b3a73a Merge pull request #184 from github/args-constraint
Consistently institute constraints for position arguments and improve error message
2021-09-24 16:02:36 +02:00
Mislav Marohnić
92d0abd6ab Merge pull request #79 from github/raffo/delete-codespaces
Add code and command to delete unused codespaces
2021-09-24 16:02:05 +02:00
Mislav Marohnić
3d017b2824 Fix stderr output on delete errors 2021-09-24 15:09:41 +02:00
Mislav Marohnić
d853ce5bc9 Avoid resolving executable() until requested at runtime
This is to avoid hitting the filesystem and resolving symlinks
unnecessarily. The value of executable is just used conditionally by a
handful of commands.
2021-09-24 14:42:41 +02:00
Mislav Marohnić
75c1dfdf49 Fetch codespace by name directly if name argument given 2021-09-23 18:57:22 +02:00
Jose Garcia
f4396e8f1a Inline go-liveshare with history 2021-09-23 11:28:04 -04:00
Mislav Marohnić
e8212a80a9 Print delete failures as they occur 2021-09-23 17:14:25 +02:00
Mislav Marohnić
1232dba684 Merge remote-tracking branch 'origin' into raffo/delete-codespaces 2021-09-23 16:43:22 +02:00
Jose Garcia
fb12f4108f Merge pull request #181 from github/jg/poll-on-async-creation
ghcs create: poll for codespaces that are being retried by the server
2021-09-23 10:10:57 -04:00
Jose Garcia
4e0ac15fe0 Add buffer to channels to avoid goroutine leak 2021-09-22 15:10:47 -04:00
Jose Garcia
9a558bc58c Early return if polling is not required
- Add context to errors in poller
2021-09-22 15:03:12 -04:00
Mislav Marohnić
7a91ba5942 Print usage help when args given to "NoArgs" commands 2021-09-22 19:51:12 +02:00
Mislav Marohnić
a55f7af92c Correct wrong args constraints 2021-09-22 19:36:25 +02:00
Jose Garcia
208f1721b5 Rename ProvisionCodespaceParams 2021-09-22 13:21:02 -04:00
Jose Garcia
70a2ea2e6a PR Feedback
- Rename ProvisionCodespace -> CreateCodespace
- Rename createCodespace -> startCreate
- Additional docs/comments
- Simplify ProvisionCodespaceParams
2021-09-22 13:19:26 -04:00
Jose Garcia
d2d21996bc Move ProvisionCodespace to API client
- Make CreateCodespace private along with its errors
2021-09-22 11:49:41 -04:00
Mislav Marohnić
32d3a38465 Name of the codespace 2021-09-22 16:39:50 +02:00
Mislav Marohnić
cb7b535b91 Add tests for delete 2021-09-22 16:11:34 +02:00
Jose Garcia
86717f14a1 Implement codespaces.Provision
- Move polling logic into the Provision function
- Document the behavior expected of callers when an ErrCreateAsyncRetry
  is returned
2021-09-22 09:09:09 -04:00
Jose Garcia
48e3473a95 PR Feedback
- Bring context.Timeout into the poller
- Accept duration and interval
- Other tidy up
2021-09-21 18:18:30 -04:00
Mislav Marohnić
678da44c28 Simplify delete further 2021-09-21 21:09:26 +02:00
Mislav Marohnić
ab86739b6b Merge remote-tracking branch 'origin' into mislav/delete-codespaces 2021-09-21 20:35:58 +02:00
Jose Garcia
861811baf0 Upgrade pkg name after merge 2021-09-21 14:02:05 -04:00
Jose Garcia
d5b03df406 Merge branch 'main' of github.com:github/ghcs into jg/poll-on-async-creation 2021-09-21 14:01:37 -04:00
Jose Garcia
323462ca5c Poll codespace on ErrCreateAsyncRetry error
- Introduce tests for the poller
- Attempt to fetch codespace for 2 mins
2021-09-21 12:37:11 -04:00
Mislav Marohnić
683d847dd2 Merge remote-tracking branch 'origin' into cli-migration 2021-09-21 17:38:41 +02:00
Jose Garcia
8a53c4369e Merge pull request #179 from github/jg/close-session
liveshare: close sessions
2021-09-21 10:14:22 -04:00
Jose Garcia
e8e914c220 PR Feedback
- Upgrade to go-liveshare v0.19.0
- Remove export helper method
- Use local implementation
2021-09-21 10:05:48 -04:00
Alan Donovan
0f88081bfa Merge pull request #178 from github/check-authorized-keys
ghcs ssh: check user has authorised SSH keys
2021-09-21 10:03:45 -04:00