From 56d59fca7df2567e99a31210179b9e4b2d6c1a85 Mon Sep 17 00:00:00 2001 From: "Matthew \"strager\" Glazar" Date: Sat, 17 Aug 2024 19:36:24 -0400 Subject: [PATCH] fix(build): work with Git-less Homebrew 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. --- tools/collect-copyright | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tools/collect-copyright b/tools/collect-copyright index fe8487ddd0..7c82f64f24 100755 --- a/tools/collect-copyright +++ b/tools/collect-copyright @@ -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(