Skip to content

fix(cli): polish doctor diagnostics, add registry file locking, and exact match gitignore - #78

Merged
JacksonFergusonDev merged 1 commit into
mainfrom
fix/cli-doctor-locking-and-gitignore
Aug 22, 2026
Merged

fix(cli): polish doctor diagnostics, add registry file locking, and exact match gitignore#78
JacksonFergusonDev merged 1 commit into
mainfrom
fix/cli-doctor-locking-and-gitignore

Conversation

@JacksonFergusonDev

Copy link
Copy Markdown
Owner

Summary

This PR completes the codebase audit polish items (P2):

  1. Removed Duplicate Doctor Diagnostics: Cleaned up the redundant second log check block in run_doctor in src/git_pulsar/cli.py.
  2. Registry Concurrency & File Locking: Wrapped REGISTRY_FILE reading and atomic updating with fcntl.flock (LOCK_SH for reads in system.get_registered_repos, LOCK_EX for writes in cli.setup_repo, cli.unregister_repo, and daemon.prune_registry) to prevent race conditions during concurrent daemon and CLI operations.
  3. Exact Line Matching for .gitignore Rules: Updated pattern checks in cli.setup_repo and ops.add_ignore from substring containment (pattern in content) to exact stripped line comparison (pattern.strip() in {line.strip() for line in lines}), preventing false positives when pattern names are substrings of existing ignore rules or comments.

Changes

  • src/git_pulsar/cli.py: Removed duplicate _analyze_logs block in run_doctor; added fcntl.flock to setup_repo and unregister_repo; added exact line matching for default ignores.
  • src/git_pulsar/daemon.py: Added fcntl.flock during atomic prune_registry.
  • src/git_pulsar/system.py: Added shared fcntl.flock in get_registered_repos.
  • src/git_pulsar/ops.py: Switched add_ignore to exact line matching.
  • tests/test_cli.py: Added tests for exact .gitignore defaults matching and unregister_repo.
  • tests/test_ops.py: Added test for exact line matching in ops.add_ignore.

Verification

  • uv run pytest --cov passed (102 tests, 67.8% coverage).
  • bash scripts/test_distributed.sh passed.
  • uv run ruff check ., uv run ruff format --check ., and uv run mypy . passed cleanly.

…xact match gitignore

- Remove duplicate log checking execution block from run_doctor in cli.py
- Add file locking (fcntl.flock) on REGISTRY_FILE reads and writes across system.py, cli.py, and daemon.py
- Switch .gitignore presence checks from substring containment to exact line matching in setup_repo and add_ignore
- Add unit tests for exact .gitignore line matching and registry unregistration
@JacksonFergusonDev
JacksonFergusonDev merged commit 205a7cc into main Aug 22, 2026
7 checks passed
@JacksonFergusonDev
JacksonFergusonDev deleted the fix/cli-doctor-locking-and-gitignore branch August 22, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant