Skip to content

Fix path boundary matching in project directory filtering#37

Draft
ShadowDog007 with Copilot wants to merge 2 commits into
mainfrom
copilot/list-csproj-projects
Draft

Fix path boundary matching in project directory filtering#37
ShadowDog007 with Copilot wants to merge 2 commits into
mainfrom
copilot/list-csproj-projects

Conversation

Copilot AI commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

The --changed-in, --changed-from, and --changed-to filters incorrectly matched projects when one project's directory name was a prefix of another (e.g., /ProjectA matching changes in /ProjectAExtensions).

Root Cause

String.startsWith was used for path matching without enforcing a path boundary separator:

'/ProjectAExtensions/file.cs'.startsWith('/ProjectA') // true — wrong

This caused false positives in two places:

  • BaseProjectFilterCommand.filterChangedFromTo — matching changed files to project dirs
  • RepositoryService.getLatestPathVersion — matching uncommitted changes to project paths

Fix

  • BaseProjectFilterCommand.ts: c.startsWith(d)c === d || c.startsWith(d + '/')
  • RepositoryService.ts: same fix for uncommitted path matching, with special-casing for the root path /

Tests Added

  • RepositoryService.spec.ts: uncommitted change in /ProjectAExtensions/file.cs must not affect getLatestPathVersion('/ProjectA')
  • ListCommand.spec.ts: --changed-in scoped to project1extensions/ must not match the project1 project

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: ShadowDog007 <3084997+ShadowDog007@users.noreply.github.com>
Copilot AI changed the title [WIP] Add functionality to list csproj projects in repository Fix path boundary matching in project directory filtering Mar 15, 2026
Copilot AI requested a review from ShadowDog007 March 15, 2026 02:16
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.

2 participants