hmarr / codeowners

🔒 Command line tool and Go library for CODEOWNERS files
MIT License
167 stars 19 forks source link

`ParseFile` issues on Windows #15

Closed AgnesToulet closed 1 year ago

AgnesToulet commented 1 year ago

Hello!

I noticed some issues running this library on Windows. Using os.PathSeparator here converts this path /test/public into this regexp "\\Atest\\public\\.*\\z" and this makes the regexp.Compile function return this error:

error parsing regexp: invalid character class range: `\pu`

This specific issue can be fixed by always using / as a separator but I don't know if it introduces errors in other functions.

hmarr commented 1 year ago

Hi, thanks for reporting this! I don't have a Windows computer to hand, but I got CI running on Windows in #16, and I think I've fixed the issue there.

Patterns should always use /, so the use of os.PathSeparator was an oversight there. For the paths to test against it's a little more subtle as you could feasibly be testing against paths on your local (Windows) filesystem or e.g. paths in a repo you've fetched via the GitHub API, so I decided to normalise paths to using forward slashes to cover both cases. That adds and allocation when the normalisation does need to happen but shouldn't affect performance when normalisation isn't required.

Would you mind testing that branch and seeing if it fixes the issue for you?

hmarr commented 1 year ago

I just published v1.1.2, which includes that fix. Hopefully that did the job but let know if you're still having issues!