Skip to content

Commit

Permalink
fix(build): work with Git-less Homebrew
Browse files Browse the repository at this point in the history
Historically, Homebrew cloned the homebrew/core tap using Git. Nowadays,
Homebrew might run in a mode where the tap is not cloned from Git. This
causes 'git rev-parse HEAD' in collect-copyright to fail.

Use the tap_git_head data from the INSTALL_RECEIPT.json file instead.
This data is more accurate and it works in Git-less Homebrew.
  • Loading branch information
strager committed Aug 17, 2024
1 parent f575f08 commit 56d59fc
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions tools/collect-copyright
Original file line number Diff line number Diff line change
Expand Up @@ -538,13 +538,9 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
tap = install_receipt["source"]["tap"]
if tap != "homebrew/core":
raise Exception(f"Unsupported tap for formula {formula_name}: {tap}")
tap_git_commit = install_receipt["source"]["tap_git_head"]

formula_rb_path = pathlib.Path(install_receipt["source"]["path"])
# TODO(strager): Get the exact version installed, not the latest
# version.
tap_git_commit = subprocess.check_output(
["git", "rev-parse", "HEAD"], encoding="utf-8", cwd=formula_rb_path.parent
).rstrip("\n")
formula_rb_repo_path = self._relative_path_within_git_checkout(formula_rb_path)

return self.InstalledPackage(
Expand Down

0 comments on commit 56d59fc

Please sign in to comment.