This commit hacks the existing repo clone tests into something usable by
the new isolated command. It went ok and was less effort than trying to
introduce the same kind of test format as repo view and gist create.
After a person copies `hosts.yml` to a headless system, they will still
be forced to go through re-authentication flow unless they copy or
initialize a `config.yml` as well. This fixes respecting authentication
info from `hosts.yml` even if `config.yml` is missing.
Read from and write to the `hosts.yml` file every time `config.yml` is
accessed. Everything that before went under the `hosts:` map now belongs
to `hosts.yml`.
We dynamically add hosts on `Set`, so this `hosts` cache might fall out
of date. We could ensure to keep it updated, but I'm not convinced it's
necessary for speed right now.
Previously we would trigger OAuth flow when the config file did not
exist. Now we will let an empty Config object be initialized in that
case, but trigger OAuth flow when the Context caller requests an
AuthToken.
The login name of the authenticated user will be readily available only
if authentication info comes from the config file. With other upcoming
authentication modes (for example, the GITHUB_TOKEN environment
variable), the token is the only piece of information we got, so we
would need to additionally query for the login name.
Since `issue status` and `pr status` are the only commands that need the
name of the authenticated user right now, have those commands explicitly
query for the login name. This results in an additional API query, but
simplifies Context implementation and future authentication approaches.
How this works for people with existing OAuth tokens:
$ gh issue list -L1
Notice: additional authorization required
Press Enter to open github.com in your browser...
[auth flow in the browser...]
Authentication complete. Press Enter to continue...
Showing 1 of 132 issues in cli/cli
...
Users of Personal Access Tokens get a different notice:
Warning: gh now requires the `read:org` OAuth scope.
Visit https://github.com/settings/tokens and edit your token to enable `read:org`
or generate a new token and paste it via `gh config set -h github.com oauth_token MYTOKEN`