Rm unnecessary warning msg "Failed to read git credential file" (#1479)

* Rm unnecessary warning msg "Failed to read git credential file"

Fixed #1476

If `gh auth token` executed successfully and binstall obtained a gh
token from it, then there's no reason to issue any warning msg.

Only when binstall cannot read from `.git-credential` and
`gh auth token` failed does binstall need to issue warning.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix clippy warning

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

---------

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-11-09 08:06:32 +10:00 committed by GitHub
parent 3414c4ee83
commit d76a40bf7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 29 deletions

View file

@ -114,7 +114,14 @@ pub fn install_crates(
if args.no_discover_github_token {
None
} else {
git_credentials::try_from_home().or_else(gh_token::get)
git_credentials::try_from_home().or_else(|| match gh_token::get() {
Ok(token) => Some(token),
Err(err) => {
warn!(?err, "Failed to retrieve token from `gh auth token`");
warn!("Failed to read git credential file");
None
}
})
}
}),
);