fix(rebuild): restore both trusted Homebrew taps before switch

This commit is contained in:
hermes committed 2026-11-29 13:29:44 -05:00
1 parent e4c67f0080
commit 80fb47f050
3 files changed
+44 -2

No files matched your search

+1
View File
@@ -103,6 +103,7 @@ Before the switch:
- `no-mistakes update`, using `~/.no-mistakes/bin/no-mistakes`, or the command on `PATH` if that binary is absent.
- `hermes update --yes`, which pulls the configured channel and restarts the services that run its new code.
- `nix flake update`, so the switch builds from the newest locked inputs. Commit the resulting `flake.lock` change.
- `brew trust can1357/tap` and `brew trust incoai/tap`, so `brew bundle` can install formulae from those third-party taps. Trust can revert between runs, so every rebuild restores it. The `whisper-cpp was renamed to whisper.cpp` notice is a warning. It does not abort the rebuild.
During the switch:
+8
View File
@@ -195,6 +195,14 @@ else
echo "==> WARNING: flake update failed. Continuing with locked inputs."
fi
# Trust third-party Homebrew taps before the switch. `brew bundle` refuses to
# install formulae from an untrusted tap, and a trust can revert between runs.
# The whisper-cpp rename notice is only a warning and stays harmless here.
if command -v brew >/dev/null 2>&1; then
brew trust can1357/tap 2>/dev/null || true
brew trust incoai/tap 2>/dev/null || true
fi
sudo darwin-rebuild switch --flake ~/.dotfiles#lt-mbp
# Update tracked skills after activation. Exclude security-audit to preserve
+35 -2
View File
@@ -105,6 +105,15 @@ elif kind in ("no-mistakes", "hermes", "nix", "npx", "pi"):
else:
state["components"][kind] = "new"
save()
elif kind == "brew":
if state.get("fail_brew_trust"):
sys.exit(1)
trusted = state.setdefault("trusted_taps", [])
if len(args) >= 2 and args[0] == "trust" and args[1] not in trusted:
trusted.append(args[1])
# The rename notice is a harmless brew warning, never a rebuild failure.
print("Warning: Formula whisper-cpp was renamed to whisper.cpp.")
save()
elif kind == "sudo":
sys.exit(state.get("switch_status", 0))
else:
@@ -174,7 +183,9 @@ class RebuildUpdates(unittest.TestCase):
self.state = json.loads((self.root / "state.json").read_text())
self.calls = [json.loads(line) for line in
(self.root / "calls.jsonl").read_text().splitlines()]
self.assertFalse(any(call[0] in ("brew", "bare-npm") for call in self.calls))
self.assertFalse(any(call[0] == "bare-npm" for call in self.calls))
self.assertFalse(any(call[0] == "brew" and (len(call) < 2 or call[1] != "trust")
for call in self.calls))
self.assertFalse(any(call[:2] == ["npm", "view"] and
call[2] in ACTIVATION_GLOBALS for call in self.calls))
self.assertEqual(Path(os.readlink(self.home / ".dotfiles")), ROOT)
@@ -210,6 +221,27 @@ class RebuildUpdates(unittest.TestCase):
self.execute()
self.assertFalse(any(call[:2] == ["npm", "install"] for call in self.calls))
def test_brew_trust_is_restored_before_switch(self):
output = self.execute()
self.assert_update_order()
trust_calls = [call for call in self.calls if call[0] == "brew"]
self.assertEqual(trust_calls, [
["brew", "trust", "can1357/tap"],
["brew", "trust", "incoai/tap"],
])
switch_index = next(i for i, call in enumerate(self.calls)
if call[0] == "sudo")
self.assertLess(self.calls.index(trust_calls[-1]), switch_index)
self.assertEqual(self.state["trusted_taps"],
["can1357/tap", "incoai/tap"])
self.assertIn("whisper-cpp was renamed", output)
self.assertNotIn("brew bundle failed", output)
def test_brew_trust_failure_still_switches(self):
self.state["fail_brew_trust"] = True
self.execute()
self.assertTrue(any(call[0] == "sudo" for call in self.calls))
def test_deleted_upstream_skills_never_reach_the_cli(self):
denied = (ROOT / "deleted-upstream-skills.txt").read_text().split()
self.assertEqual(len(denied), 20)
@@ -267,7 +299,8 @@ class RebuildUpdates(unittest.TestCase):
(self.home / ".no-mistakes/bin/no-mistakes").unlink()
output = self.execute()
self.assertGreaterEqual(output.count("WARNING:"), 5)
self.assertEqual([call[0] for call in self.calls], ["nix", "sudo"])
self.assertEqual([call[0] for call in self.calls],
["nix", "brew", "brew", "sudo"])
def test_no_mistakes_path_fallback(self):
(self.home / ".no-mistakes/bin/no-mistakes").unlink()