Skip to content

Commit 9ae2838

Browse files
committed
Fix dead code and uninstall regression in hook installer
- Remove unused _entry_matches_command function (dead code never called) - Fix _strip_command_from_matcher_entry to preserve entries that don't contain the target command (previously entries with empty hooks arrays were silently dropped even if unrelated to primer)
1 parent ab01dae commit 9ae2838

1 file changed

Lines changed: 2 additions & 18 deletions

File tree

src/primer/hook/installer.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -180,24 +180,6 @@ def _install_claude(settings: dict, config: AgentHookConfig) -> bool:
180180
return already_end and already_compact
181181

182182

183-
def _entry_matches_command(entry: object, command: str) -> bool:
184-
"""True if a hook list entry (any supported format) references `command`."""
185-
if isinstance(entry, str):
186-
return entry == command
187-
if not isinstance(entry, dict):
188-
return False
189-
# Legacy flat format
190-
if entry.get("command") == command:
191-
return True
192-
# Matcher-wrapped format — entry matches if any inner hook targets the command
193-
inner_hooks = entry.get("hooks", [])
194-
if isinstance(inner_hooks, list):
195-
for inner in inner_hooks:
196-
if isinstance(inner, dict) and inner.get("command") == command:
197-
return True
198-
return False
199-
200-
201183
def _strip_command_from_matcher_entry(entry: dict, command: str) -> dict | None:
202184
"""Remove the command from a matcher-wrapped entry, returning a cleaned
203185
entry or None if no inner hooks remain."""
@@ -207,6 +189,8 @@ def _strip_command_from_matcher_entry(entry: dict, command: str) -> dict | None:
207189
remaining = [
208190
h for h in inner_hooks if not (isinstance(h, dict) and h.get("command") == command)
209191
]
192+
if len(remaining) == len(inner_hooks):
193+
return entry
210194
if not remaining:
211195
return None
212196
cleaned = dict(entry)

0 commit comments

Comments
 (0)