MCPcopy Create free account
hub / github.com/FastLED/FastLED / count_stale_worktrees

Function count_stale_worktrees

ci/hooks/check-on-stop.py:270–295  ·  view source on GitHub ↗

Count directories under .claude/worktrees/. Iterates with an explicit loop so failures surface a descriptive error on stderr (per coding-standards "no silent fallbacks") while still keeping the stop-hook itself non-fatal — the loop body propagates the underlying OSError up.

()

Source from the content-addressed store, hash-verified

268
269
270def count_stale_worktrees() -> int:
271 """Count directories under .claude/worktrees/.
272
273 Iterates with an explicit loop so failures surface a descriptive error
274 on stderr (per coding-standards "no silent fallbacks") while still
275 keeping the stop-hook itself non-fatal — the loop body propagates the
276 underlying OSError up.
277 """
278 if not WORKTREES_DIR.exists():
279 return 0
280 try:
281 iterator = WORKTREES_DIR.iterdir()
282 except KeyboardInterrupt:
283 import _thread
284
285 _thread.interrupt_main()
286 raise
287 except OSError as exc:
288 raise OSError(
289 f"count_stale_worktrees: cannot iterate {WORKTREES_DIR}: {exc}"
290 ) from exc
291 count = 0
292 for p in iterator:
293 if p.is_dir() and not p.is_symlink():
294 count += 1
295 return count
296
297
298def warn_stale_worktrees() -> None:

Callers 1

warn_stale_worktreesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected