From 84cb8a42f7a333062959fad19188160ab31795eb Mon Sep 17 00:00:00 2001
From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
Date: Mon, 8 May 2023 11:37:48 +0800
Subject: [PATCH] Revert "Revert "Merge pull request #15369 from
carlocab/sorbet-runtime""
We need to exclude any command that might read `lsyncd` on Linux while
simulating macOS. This seems like all of them.
This reverts commit bcf94f6e27d26a6844ee1fa7af73333321015987.
---
Library/Homebrew/brew.sh | 24 ++++++++++++++++++++++++
Library/Homebrew/env_config.rb | 3 ++-
docs/Manpage.md | 2 +-
manpages/brew.1 | 2 +-
4 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh
index 35a74283fc..c72d8fc8a3 100644
--- a/Library/Homebrew/brew.sh
+++ b/Library/Homebrew/brew.sh
@@ -883,6 +883,30 @@ then
fi
fi
+if [[ -n "${HOMEBREW_DEVELOPER}" || -n "${HOMEBREW_DEVELOPER_COMMAND}" ]]
+then
+ # Always run with Sorbet for Homebrew developers or Homebrew developer commands.
+ export HOMEBREW_SORBET_RUNTIME="1"
+fi
+
+# NO_SORBET_RUNTIME_COMMANDS are currently failing with Sorbet for homebrew/core.
+# TODO: fix this and remove this if block.
+if [[ -n "${HOMEBREW_SORBET_RUNTIME}" ]]
+then
+ NO_SORBET_RUNTIME_COMMANDS=(
+ audit
+ determine-test-runners
+ readall
+ )
+
+ if check-array-membership "${HOMEBREW_COMMAND}" "${NO_SORBET_RUNTIME_COMMANDS[@]}"
+ then
+ unset HOMEBREW_SORBET_RUNTIME
+ fi
+
+ unset NO_SORBET_RUNTIME_COMMANDS
+fi
+
if [[ -n "${HOMEBREW_DEVELOPER_COMMAND}" && -z "${HOMEBREW_DEVELOPER}" ]]
then
if [[ -z "${HOMEBREW_DEV_CMD_RUN}" ]]
diff --git a/Library/Homebrew/env_config.rb b/Library/Homebrew/env_config.rb
index 5884ea4b05..70bfdabda4 100644
--- a/Library/Homebrew/env_config.rb
+++ b/Library/Homebrew/env_config.rb
@@ -357,7 +357,8 @@ module Homebrew
boolean: true,
},
HOMEBREW_SORBET_RUNTIME: {
- description: "If set, enable runtime typechecking using Sorbet.",
+ description: "If set, enable runtime typechecking using Sorbet. " \
+ "Set by default for HOMEBREW_DEVELOPER or when running developer commands.",
boolean: true,
},
HOMEBREW_SSH_CONFIG_PATH: {
diff --git a/docs/Manpage.md b/docs/Manpage.md
index 380b157e96..e1928d2fe1 100644
--- a/docs/Manpage.md
+++ b/docs/Manpage.md
@@ -2275,7 +2275,7 @@ example, run `export HOMEBREW_NO_INSECURE_REDIRECT=1` rather than just
If set along with `HOMEBREW_DEVELOPER`, do not use bottles from older versions of macOS. This is useful in development on new macOS versions.
- `HOMEBREW_SORBET_RUNTIME`
-
If set, enable runtime typechecking using Sorbet.
+
If set, enable runtime typechecking using Sorbet. Set by default for HOMEBREW_DEVELOPER or when running developer commands.
- `HOMEBREW_SSH_CONFIG_PATH`
If set, Homebrew will use the given config file instead of `~/.ssh/config` when fetching `git` repos over `ssh`.
diff --git a/manpages/brew.1 b/manpages/brew.1
index 084df9013a..d068480138 100644
--- a/manpages/brew.1
+++ b/manpages/brew.1
@@ -3354,7 +3354,7 @@ If set along with \fBHOMEBREW_DEVELOPER\fR, do not use bottles from older versio
\fBHOMEBREW_SORBET_RUNTIME\fR
.
.br
-If set, enable runtime typechecking using Sorbet\.
+If set, enable runtime typechecking using Sorbet\. Set by default for HOMEBREW_DEVELOPER or when running developer commands\.
.
.TP
\fBHOMEBREW_SSH_CONFIG_PATH\fR