From 3e0d7363a50be55369012957a253478f71af7f9f Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Sat, 11 Mar 2023 18:10:40 +1100 Subject: [PATCH] Read from env `GH_TOKEN` for github_token as a fallback (#883) Signed-off-by: Jiahao XU --- crates/bin/src/args.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/bin/src/args.rs b/crates/bin/src/args.rs index 8823cd12..ee9581bf 100644 --- a/crates/bin/src/args.rs +++ b/crates/bin/src/args.rs @@ -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()); + } } }