Merge pull request #15500 from carlocab/no-load-gh

utils/github/api: avoid loading `gh`
This commit is contained in:
Carlo Cabrera 2023-06-01 00:01:54 +08:00 committed by GitHub
commit d684472b13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -126,7 +126,8 @@ module GitHub
# Gets the token from the GitHub CLI for github.com.
sig { returns(T.nilable(String)) }
def self.github_cli_token
env = { "PATH" => PATH.new(Formula["gh"].opt_bin, ENV.fetch("PATH")) }
# Avoid `Formula["gh"].opt_bin` so this method works even with `HOMEBREW_DISABLE_LOAD_FORMULA`.
env = { "PATH" => PATH.new(HOMEBREW_PREFIX/"opt/gh/bin", ENV.fetch("PATH")) }
gh_out, _, result = system_command "gh",
args: ["auth", "token", "--hostname", "github.com"],
env: env,