Fix .gitignore pattern mismatch in removePiLoopFromGitignore #46

Closed
opened 2026-07-30 00:35:13 +00:00 by david · 1 comment
Owner

Problem

When a user's .gitignore contains .pi-loop (without trailing slash), removePiLoopFromGitignore() fails to remove it because it only matches .pi-loop/ (with trailing slash). This causes git add -- . :(exclude).pi-loop in the MR stage to fail:

git add -- . :(exclude).pi-loop
The following paths are ignored by one of your .gitignore files:
.pi-loop

Root Cause

src/run/services/gitExclude.tsremovePiLoopFromGitignore() uses exact match against EXCLUDE_ENTRY = '.pi-loop/':

const filtered = lines.filter((line) => line.trim() !== EXCLUDE_ENTRY);

.pi-loop.pi-loop/ → line stays in .gitignoregit add fails.

Fix

Broaden removePiLoopFromGitignore() to match three patterns:

  • .pi-loop (no slash)
  • .pi-loop/ (trailing slash — already handled)
  • /.pi-loop (root-anchored)

Acceptance Criteria

  • removePiLoopFromGitignore() removes lines matching .pi-loop, .pi-loop/, or /.pi-loop
  • Lines with .pi-loop as a substring (e.g. .pi-loop-extra/) are NOT removed
  • New tests added for .pi-loop (no slash) and /.pi-loop (root-anchored) removal
  • Existing substring-safety test updated to reference all three patterns
  • npm run lint and npm test pass

Files to Change

  • src/run/services/gitExclude.ts — broaden pattern matching
  • src/run/services/gitExclude.test.ts — add two new tests, update substring safety test
## Problem When a user's `.gitignore` contains `.pi-loop` (without trailing slash), `removePiLoopFromGitignore()` fails to remove it because it only matches `.pi-loop/` (with trailing slash). This causes `git add -- . :(exclude).pi-loop` in the MR stage to fail: ``` git add -- . :(exclude).pi-loop The following paths are ignored by one of your .gitignore files: .pi-loop ``` ## Root Cause `src/run/services/gitExclude.ts` — `removePiLoopFromGitignore()` uses exact match against `EXCLUDE_ENTRY = '.pi-loop/'`: ```typescript const filtered = lines.filter((line) => line.trim() !== EXCLUDE_ENTRY); ``` `.pi-loop` ≠ `.pi-loop/` → line stays in `.gitignore` → `git add` fails. ## Fix Broaden `removePiLoopFromGitignore()` to match three patterns: - `.pi-loop` (no slash) - `.pi-loop/` (trailing slash — already handled) - `/.pi-loop` (root-anchored) ## Acceptance Criteria - [ ] `removePiLoopFromGitignore()` removes lines matching `.pi-loop`, `.pi-loop/`, or `/.pi-loop` - [ ] Lines with `.pi-loop` as a substring (e.g. `.pi-loop-extra/`) are NOT removed - [ ] New tests added for `.pi-loop` (no slash) and `/.pi-loop` (root-anchored) removal - [ ] Existing substring-safety test updated to reference all three patterns - [ ] `npm run lint` and `npm test` pass ## Files to Change - `src/run/services/gitExclude.ts` — broaden pattern matching - `src/run/services/gitExclude.test.ts` — add two new tests, update substring safety test
Author
Owner

Fixed in #47.

Fixed in [#47](https://git.excelera.net/david/pi-loop/pulls/47).
david closed this issue 2026-07-30 20:49:08 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
david/pi-loop#46
No description provided.