Conversation
- Add same-path guard in init_workspace() before any copy - Reuse the existing WorkspaceError CLI error path - Add unit test for direct init_workspace() rejection - Add integration test for CLI init --force rejection - Source checkout is left unchanged after rejection Closes abhiksark#71
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📜 Recent review details🧰 Additional context used📓 Path-based instructions (3)Keep Textual imports out of `pythonlings/core/` and one-shot CLI command import paths.📄 CodeRabbit inference engine (AGENTS.md) Files:
Maintain Python 3.9 compatibility.📄 CodeRabbit inference engine (AGENTS.md) Files:
Preserve learner-edited exercises during workspace updates.📄 CodeRabbit inference engine (AGENTS.md) Files:
🔇 Additional comments (3)
📝 WalkthroughWalkthrough
ChangesCurriculum source initialization guard
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change implements the intended source-directory protection and preserves the established CLI error behavior without an identified merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit guards the source-tree door Comment |
Summary
Fixes #71
init --path <curriculum-source> --forcewas crashing withshutil.SameFileErrorbecauseinit_workspace()started copying before checking whether the destination resolved to the curriculum source.update_workspace()already had the equivalent guard; this adds the same guard toinit_workspace().Changes
pythonlings/core/curriculum.py: reject forced init whenpath == source_root()before any copy or removal, raisingWorkspaceErrorwith a concise message.tests/unit/test_curriculum.py: directinit_workspace()regression test for the same-path case.tests/integration/test_cli_workspace.py: CLI-level regression test asserting non-zero exit and cleanpythonlings: erroroutput, plus that the source checkout is unchanged.Acceptance checklist
init --path <curriculum-source> --forceexits non-zero without a traceback.Tests
Same-path repro (disposable copy):
Checklist
python -m pytest -qSummary by CodeRabbit
init --forcecommand now exits with an error and preserves existing files when used on the source directory.