Skip to content

fix: preserve workspace gitignore entries - #53

Open
fzlzjerry wants to merge 2 commits into
abhiksark:mainfrom
fzlzjerry:fix/43-preserve-gitignore
Open

fix: preserve workspace gitignore entries#53
fzlzjerry wants to merge 2 commits into
abhiksark:mainfrom
fzlzjerry:fix/43-preserve-gitignore

Conversation

@fzlzjerry

@fzlzjerry fzlzjerry commented Aug 9, 2026

Copy link
Copy Markdown

Summary

  • preserve existing workspace .gitignore content during force-init and update
  • append only missing Pythonlings-managed patterns in their declared order
  • keep repeated init and update operations idempotent

Closes #43

Tests

  • python -m pytest -q (Python 3.11: 150 passed)
  • python -m pytest tests/unit/test_curriculum.py tests/integration/test_cli_workspace.py -q (Python 3.13: 13 passed)

Screenshots

Not applicable; this changes filesystem behavior without changing CLI output.

Checklist

  • Documentation is unchanged because the commands and managed patterns are unchanged
  • Added or updated tests
  • Verified python -m pytest -q

Summary by CodeRabbit

  • Bug Fixes

    • Workspace initialization and updates now preserve existing .gitignore entries.
    • Required Pythonlings and Python ignore patterns are appended only when missing.
    • Repeated initialization and updates no longer rewrite unchanged .gitignore files.
    • Existing line-ending styles are preserved.
  • Tests

    • Added coverage for standard, forced, and update workspace flows, including empty and pre-populated .gitignore files.

Signed-off-by: Morax <james20081204@gmail.com>
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ca2d91c7-abea-4023-b0be-c095ea141321

📥 Commits

Reviewing files that changed from the base of the PR and between 44b5cd4 and b481327.

📒 Files selected for processing (2)
  • pythonlings/core/curriculum.py
  • tests/unit/test_curriculum.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • pythonlings/core/curriculum.py
  • tests/unit/test_curriculum.py

📝 Walkthrough

Walkthrough

The workspace gitignore writer preserves existing entries and appends only missing managed patterns. Initialization and update tests cover normal, forced, empty, CRLF, and repeated operations.

Changes

Workspace gitignore preservation

Layer / File(s) Summary
Preserve and append gitignore entries
pythonlings/core/curriculum.py
_write_workspace_gitignore reads existing .gitignore content, preserves existing entries, appends missing managed entries, and avoids unnecessary rewrites.
Validate initialization and update behavior
tests/unit/test_curriculum.py, tests/integration/test_cli_workspace.py
Tests cover normal initialization, forced initialization, updates, empty files, CRLF line endings, existing rules, and idempotent repeated operations.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A rabbit guards each ignore line,
Keeps old rules safe and fine.
Adds missing patterns, one by one,
No duplicates when work is done.
Hop, hop—clean files align!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: preserving existing workspace .gitignore entries.
Description check ✅ Passed The description includes all required sections, summarizes the change, documents tests, and completes the checklist.
Linked Issues check ✅ Passed The implementation and tests address issue #43, including preservation, ordered appends, idempotency, and init, force-init, and update paths.
Out of Scope Changes check ✅ Passed The changes are limited to workspace .gitignore handling and related unit and integration tests.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@fzlzjerry
fzlzjerry marked this pull request as ready for review August 11, 2026 08:57
Copilot AI lite review requested due to automatic review settings August 11, 2026 08:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pythonlings/core/curriculum.py`:
- Around line 74-77: Update the `.gitignore` append logic around
`gitignore.open` to detect the existing file’s line-ending convention and use it
consistently for the separator and all `missing_lines`; preserve CRLF files as
CRLF and retain the current behavior for files without an existing convention.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1c181795-5823-4d49-b45c-919ae305b1b8

📥 Commits

Reviewing files that changed from the base of the PR and between e3bdcc9 and 44b5cd4.

📒 Files selected for processing (3)
  • pythonlings/core/curriculum.py
  • tests/integration/test_cli_workspace.py
  • tests/unit/test_curriculum.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (8)
pythonlings/core/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Core exercise loading, workspace setup, state, reset, solutions, and runner logic must live in pythonlings/core/ directory

Keep UI behavior in screens/ and widgets/ modules; keep behavior logic in core/ modules—do not import UI in core

Files:

  • pythonlings/core/curriculum.py
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Use Python 3.11+ idioms in all Python code
Use 4-space indentation in all Python code
Prefer small, typed functions where practical in Python code

**/*.py: Guard newer-stdlib usage with requires-python = ">=3.9" and use fallbacks (e.g. tomllib falls back to tomli) in modules like core/manifest.py
Include from __future__ import annotations at the top of Python modules

Files:

  • pythonlings/core/curriculum.py
  • tests/integration/test_cli_workspace.py
  • tests/unit/test_curriculum.py
pythonlings/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Keep UI behavior in screens/ or widgets/ directories; keep filesystem, manifest, reset, and runner behavior in core/

Files:

  • pythonlings/core/curriculum.py
tests/integration/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Keep integration tests in tests/integration/ directory

Files:

  • tests/integration/test_cli_workspace.py
tests/**/*test_*.py

📄 CodeRabbit inference engine (AGENTS.md)

Name test files as test_<behavior>.py

Files:

  • tests/integration/test_cli_workspace.py
  • tests/unit/test_curriculum.py
tests/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

tests/**/*.py: Name test functions as test_<expected_behavior>
Use pytest for all tests with pytest-asyncio in auto mode for async tests

Files:

  • tests/integration/test_cli_workspace.py
  • tests/unit/test_curriculum.py
**/test_*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Name tests as test_<behavior>.py or test_<expected_behavior> (e.g., test_runner.py, test_state.py)

Files:

  • tests/integration/test_cli_workspace.py
  • tests/unit/test_curriculum.py
tests/unit/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Keep unit tests in tests/unit/ directory

Files:

  • tests/unit/test_curriculum.py
🔇 Additional comments (2)
tests/integration/test_cli_workspace.py (1)

15-20: LGTM!

Also applies to: 48-62, 90-104

tests/unit/test_curriculum.py (1)

46-76: LGTM!

Also applies to: 90-103

Comment thread pythonlings/core/curriculum.py Outdated
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.

fix: preserve existing workspace .gitignore entries

2 participants