diff --git a/Library/Homebrew/dev-cmd/pr-upload.rb b/Library/Homebrew/dev-cmd/pr-upload.rb index 28a904d02d..5779874586 100644 --- a/Library/Homebrew/dev-cmd/pr-upload.rb +++ b/Library/Homebrew/dev-cmd/pr-upload.rb @@ -101,24 +101,27 @@ module Homebrew bottle_args += json_files if args.dry_run? - service = - if 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 - puts <<~EOS - brew #{bottle_args.join " "} - Upload bottles described by these JSON files to #{service}: - #{json_files.join("\n ")} - EOS - return unless github_packages?(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" + 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 #{dry_run_service}: + #{json_files.join("\n ")} + EOS + return + end end check_bottled_formulae(bottles_hash) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index a184483139..a6e1cfe2f3 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -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 diff --git a/Library/Homebrew/github_packages.rb b/Library/Homebrew/github_packages.rb index df7528468e..64e24eadf2 100644 --- a/Library/Homebrew/github_packages.rb +++ b/Library/Homebrew/github_packages.rb @@ -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 = {