formula_auditor: handle head_info being nil

This happens when CI runs on an event that isn't a pull request (e.g.
push, merge_group).
This commit is contained in:
Carlo Cabrera 2023-06-10 02:58:52 +08:00
parent 05029fc8a2
commit f13210801a
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -349,7 +349,7 @@ module Homebrew
# TODO: Remove this when OpenSSL migration is complete.
ignore_openssl_conflict = if (github_event_path = ENV.fetch("GITHUB_EVENT_PATH", nil)).present?
event_payload = JSON.parse(File.read(github_event_path))
head_info = event_payload.dig("pull_request", "head")
head_info = event_payload.dig("pull_request", "head").to_h # handle `nil`
# We need to read the head ref from `GITHUB_EVENT_PATH` because
# `git branch --show-current` returns `master` on PR branches.