Skip to content

fix: preserve existing workspace .gitignore entries #43

Description

@abhiksark

Motivation

Workspace initialization currently rewrites .gitignore with only Pythonlings-managed patterns. That silently discards learner or team ignore rules, including during forced initialization and update.

Current evidence

  • pythonlings/core/curriculum.py::_write_workspace_gitignore() writes a replacement file from GITIGNORE_LINES.
  • init_workspace() and update_workspace() both call that helper.

Exact scope

Change managed ignore handling to append only missing Pythonlings patterns. Preserve existing user lines exactly: no deletion, duplication, or reordering during init, force-init, or update.

Acceptance checklist

  • An existing .gitignore retains every original line in its original order.
  • Missing managed patterns are appended once in the declared managed-pattern order.
  • Repeated init/update operations are idempotent and do not duplicate managed patterns.
  • Empty or absent .gitignore gets the managed patterns.
  • Normal init, force-init, and update paths are all covered by tests.

Explicit exclusions

Do not normalize, sort, deduplicate, or otherwise rewrite user-authored ignore rules; do not change the managed patterns themselves.

Likely files

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

Verification

python -m pytest tests/unit/test_curriculum.py tests/integration/test_cli_workspace.py -q
python -m pytest -q

Manually inspect before/after .gitignore fixtures containing comments, blank lines, and an existing managed pattern.

Sprint coordination

See the sprint Discussion. This issue is unassigned and is not a reservation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreCore workspace, manifest, state, and runner behaviorbugSomething isn't workingdev sprintPythonlings Community Dev Sprint August 2026good first issueGood for newcomerssize: SSmall, focused contribution

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions