From ea5f91a92db450e7e038b1217e5f1b39fba7f84d Mon Sep 17 00:00:00 2001 From: Patrick Linnane Date: Wed, 12 Oct 2022 21:05:43 -0700 Subject: [PATCH] cockatrice: rebuild Fix livecheck Closes #133425. Signed-off-by: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com> --- Casks/cockatrice.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Casks/cockatrice.rb b/Casks/cockatrice.rb index 455a74ba11..306d3f4552 100644 --- a/Casks/cockatrice.rb +++ b/Casks/cockatrice.rb @@ -23,12 +23,20 @@ cask "cockatrice" do homepage "https://cockatrice.github.io/" livecheck do - url :url - strategy :github_latest do |page| - match = page.match( - %r{href=".*?/(\d+(?:-\d+)+)-Release-(\d+(?:\.\d+)+)/Cockatrice-([^/]+)-\2-macOS-[.\w]*\.dmg"}i, + url "https://github.com/Cockatrice/Cockatrice/releases/latest/" + regex(%r{href=".*?/(\d+(?:-\d+)+)-Release-(\d+(?:\.\d+)+)/Cockatrice-([^/]+)-\2-macOS-[.\w]*\.dmg"}i) + strategy :header_match do |headers, regex| + next if headers["location"].blank? + + # Identify the latest tag from the response's `location` header + latest_tag = File.basename(headers["location"]) + next if latest_tag.blank? + + # Fetch the assets list HTML for the latest tag and match within it + assets_page = Homebrew::Livecheck::Strategy.page_content( + @url.sub(%r{/releases/?.+}, "/releases/expanded_assets/#{latest_tag}"), ) - "#{match[2]},#{match[1]},#{match[3]}" + assets_page[:content]&.scan(regex)&.map { |match| "#{match[1]},#{match[0]},#{match[2]}" } end end