Skip to content

Commit

Permalink
api: use formulae.brew.sh for cask-source API again.
Browse files Browse the repository at this point in the history
GitHub's raw endpoint is proving hilariously unreliable for us here.
  • Loading branch information
MikeMcQuaid committed Feb 16, 2023
1 parent 6f195c1 commit d911868
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Library/Homebrew/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ def self.fetch_file_source(filepath, repo:, git_head: nil)
endpoint = "#{git_head}/#{filepath}"
return cache[endpoint] if cache.present? && cache.key?(endpoint)

raw_url = "https://raw.githubusercontent.com/#{repo}/#{endpoint}"
output = Utils::Curl.curl_output("--fail", raw_url)
# TODO: consider using this URL again in future if it ever stabilises and doesn't return random 404s.
# raw_url = "https://raw.githubusercontent.com/#{repo}/#{endpoint}"
formulae_brew_sh_url = "#{HOMEBREW_API_DEFAULT_DOMAIN}/api/cask-source/#{filepath}"

output = Utils::Curl.curl_output("--fail", formulae_brew_sh_url)
raise ArgumentError, "No file found at #{Tty.underline}#{raw_url}#{Tty.reset}" unless output.success?

cache[endpoint] = output.stdout
Expand Down

0 comments on commit d911868

Please sign in to comment.