Read from env GH_TOKEN for github_token as a fallback (#883)

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-03-11 18:10:40 +11:00 committed by GitHub
parent ff5276f4f4
commit 3e0d7363a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -461,11 +461,15 @@ You cannot use --{option} and specify multiple packages at the same time. Do one
.exit()
}
if opts.github_token.is_none() && !opts.no_discover_github_token {
if let Some(github_token) = try_extract_from_git_credentials() {
opts.github_token = Some(github_token);
} else if let Ok(github_token) = gh_token::get() {
if opts.github_token.is_none() {
if let Ok(github_token) = env::var("GH_TOKEN") {
opts.github_token = Some(github_token.into());
} else if !opts.no_discover_github_token {
if let Some(github_token) = try_extract_from_git_credentials() {
opts.github_token = Some(github_token);
} else if let Ok(github_token) = gh_token::get() {
opts.github_token = Some(github_token.into());
}
}
}