Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative patterns in .fantomasignore don't match any files #1713

Closed
amongonz opened this issue May 10, 2021 · 2 comments
Closed

Relative patterns in .fantomasignore don't match any files #1713

amongonz opened this issue May 10, 2021 · 2 comments
Labels
clitool Area command line tool use-from-FAKE

Comments

@amongonz
Copy link

Ignore patterns relative to the directory of .fantomasignore, such as vendored/*.fs or src/Generated.fs, don't match any files (unless the ignore file is at the root directory). A simple repro is adding the latter pattern to .fantomasignore and testing in an F# script or FSI session:

#r "nuget:Fantomas.Extras"
// Prints "IsIgnored: false"
Fantomas.Extras.IgnoreFile.isIgnoredFile "src/Generated.fs" |> printfn "IsIgnored: %b"

This is because IsIgnored is being given an absolute path, but this API interprets paths as relative to the root of the patterns, which is meant to be directory of .fantomasignore.

A simple fix would be calling Path.GetRelativePath(ignoreFileDirFullPath, fileFullPath), but for that Fantomas.Extras would have to target netstandard2.1, which is a breaking change. Alternatively, a base directory could be prepended to these patterns so they match absolute paths. That would ideally be a feature of MAB.DotIgnore, but it can be done before adding relative patterns to IgnoreList. I can create a PR once it's clear which is the best fix.

@amongonz amongonz changed the title Relative patterns in .fantomasignore don't match files any files Relative patterns in .fantomasignore don't match any files May 10, 2021
@nojaf
Copy link
Contributor

nojaf commented May 11, 2021

Hello Adrián, thank you for raising this issue.
Feels related to markashleybell/MAB.DotIgnore#9 (comment).
And I'm also considering switching to https://github.com/goelhardik/ignore in the next major, see markashleybell/MAB.DotIgnore#24.

Short term I would accept a PR that prepends the base directory to relative patterns if you think this is achievable.

@nojaf nojaf added clitool Area command line tool use-from-FAKE labels May 11, 2021
@knocte
Copy link
Contributor

knocte commented Oct 25, 2021

It seems this issue can be closed after PR#1920 has been merged.

@nojaf nojaf closed this as completed Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clitool Area command line tool use-from-FAKE
Projects
None yet
Development

No branches or pull requests

3 participants