Skip to content

Commit

Permalink
Fix exclude handling with explicit arguments
Browse files Browse the repository at this point in the history
This logic would only apply our excludes to the arguments given, not the
files post-expanded. This means if you call `restyle .` it effectively
ignores excludes.

This was mostly fine as usage on a PR will always pass fully expanded
paths, but breaks locally, particularly in our integration tests where a
`.git` directory would be picked up by shebang.

The fix is to apply excludes after expansion, but we can also apply them
before as an optimization (no use expanding if excludes happen to hit at
that level already).
  • Loading branch information
pbrisbin committed Jul 26, 2024
1 parent 2e1fd83 commit 658ab3d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Restyler/Restyler/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,20 @@ runRestylers
=> Config
-> [FilePath]
-> m (Maybe (NonEmpty RestylerResult))
runRestylers config@Config {..} allPaths = do
paths <- findFiles $ filter included allPaths
runRestylers config@Config {..} argPaths = do
let allPaths = filter included argPaths
expPaths <- findFiles allPaths
let paths = filter included expPaths

logDebug
$ "Paths"
:# [ "pathsGiven" .= argPaths
, "pathsGivenIncluded" .= allPaths
, "pathsExpanded" .= expPaths
, "pathsExpandedIncluded" .= paths
, "exclude" .= cExclude
]

for_ cRemoteFiles $ \rf -> downloadFile rf.url rf.path
withFilteredPaths restylers paths $ runRestyler config
where
Expand Down

0 comments on commit 658ab3d

Please sign in to comment.