Skip to content

Fix diff parser regex to handle filenames with spaces and special chars #25

@that-github-user

Description

@that-github-user

Summary

src/scoring/diff-parser.ts:22:

const match = line.match(/diff --git a\/(.+) b\/(.+)/);

This regex breaks on filenames with spaces. Git outputs quoted paths for such files:

diff --git a/"my file.ts" b/"my file.ts"

The regex won't capture the quotes correctly, breaking convergence analysis for repos with spaces in filenames.

Proposed fix

Handle both quoted and unquoted paths:

const match = line.match(/diff --git "?a\/(.+?)"? "?b\/(.+?)"?$/);

Test case

Add a test with a diff containing "src/my component.tsx".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions