fix(cli): polish doctor diagnostics, add registry file locking, and exact match gitignore - #78
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR completes the codebase audit polish items (P2):
run_doctorinsrc/git_pulsar/cli.py.REGISTRY_FILEreading and atomic updating withfcntl.flock(LOCK_SHfor reads insystem.get_registered_repos,LOCK_EXfor writes incli.setup_repo,cli.unregister_repo, anddaemon.prune_registry) to prevent race conditions during concurrent daemon and CLI operations.cli.setup_repoandops.add_ignorefrom 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_logsblock inrun_doctor; addedfcntl.flocktosetup_repoandunregister_repo; added exact line matching for default ignores.src/git_pulsar/daemon.py: Addedfcntl.flockduring atomicprune_registry.src/git_pulsar/system.py: Added sharedfcntl.flockinget_registered_repos.src/git_pulsar/ops.py: Switchedadd_ignoreto exact line matching.tests/test_cli.py: Added tests for exact.gitignoredefaults matching andunregister_repo.tests/test_ops.py: Added test for exact line matching inops.add_ignore.Verification
uv run pytest --covpassed (102 tests, 67.8% coverage).bash scripts/test_distributed.shpassed.uv run ruff check .,uv run ruff format --check ., anduv run mypy .passed cleanly.