GitHub Packages tweaks

- cleanup comments from #10938
- fix download URL
- remove incorrect comment
This commit is contained in:
Mike McQuaid 2021-03-30 08:42:15 +01:00
parent ab99855c12
commit d36e99c17c
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
3 changed files with 25 additions and 21 deletions

View File

@ -101,24 +101,27 @@ module Homebrew
bottle_args += json_files
if args.dry_run?
service =
if internet_archive?(bottles_hash)
dry_run_service = if github_packages?(bottles_hash)
# GitHub Packages has its own --dry-run handling.
nil
elsif internet_archive?(bottles_hash)
"Internet Archive"
elsif bintray?(bottles_hash)
"Bintray"
elsif github_releases?(bottles_hash)
"GitHub Releases"
elsif github_packages?(bottles_hash)
"GitHub Packages"
else
odie "Service specified by root_url is not recognized"
end
if dry_run_service
puts <<~EOS
brew #{bottle_args.join " "}
Upload bottles described by these JSON files to #{service}:
Upload bottles described by these JSON files to #{dry_run_service}:
#{json_files.join("\n ")}
EOS
return unless github_packages?(bottles_hash)
return
end
end
check_bottled_formulae(bottles_hash)

View File

@ -543,6 +543,8 @@ class CurlGitHubPackagesDownloadStrategy < CurlDownloadStrategy
_, org, repo, = *url.match(GitHubPackages::URL_REGEX)
# remove redundant repo prefix for a shorter name
repo = repo.delete_prefix("homebrew-")
blob_url = "#{GitHubPackages::URL_PREFIX}#{org}/#{repo}/#{name}/blobs/sha256:#{checksum}"
curl_download(blob_url, "--header", "Authorization: Bearer", to: temporary_path)
end

View File

@ -46,7 +46,6 @@ class GitHubPackages
skopeo = Formula["skopeo"].opt_bin/"skopeo"
end
# TODO: these dependencies are installed but cannot be required automatically.
Homebrew.install_gem!("json_schemer")
require "json_schemer"
@ -147,8 +146,8 @@ class GitHubPackages
source = "https://github.com/#{org}/#{repo}/blob/#{git_revision}/#{git_path}"
documentation = if formula.tap.core_tap?
"https://formulae.brew.sh/formula/#{formula_name}"
else
formula.tap.remote
elsif (remote = formula.tap.remote) && remote.start_with?("https://github.com/")
remote
end
formula_annotations_hash = {