If GH_CONFIG_DIR is set, don't auto migrate the config file. This fixes
the situation where the path given via GH_CONFIG_DIR does not exist and
the cli attempts to migrate an existing config to that location.
Fixes#3837
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>
This adds support for using the GH_CONFIG_DIR environment variable to determine
where the config files are written, this is useful for cases where the homedir
is not writable.
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`.
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.