fix(rebuild): restore both trusted Homebrew taps before switch
This commit is contained in:
1 parent
e4c67f0080
commit
80fb47f050
3 files changed
+44
-2
No files matched your search
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user