Closed NKorchagin closed 3 years ago
@NKorchagin thanks for reporting this - I'll get it fixed asap.
@NKorchagin fixed in 0.39.4
Possible regression in 0.46.3: When I run swiftformat --config .swiftformat ./**/*.swift
instead of swiftformat --config .swiftformat ./
, my exclude list will be ignored.
@palle-k using wildcards for input paths is not currently supported. I guess this works because the shell itself expands the path, but it's not something I ever tested. Are you sure it worked prior to 0.46.3?
I haven't tested it with prior versions. But I have noticed that this error also occurs in the pre-commit hook (the one described in this repo with git-format-staged
) and with single files.
@palle-k ah OK, thanks. I'll take a look.
Thanks. I was able to work around it for now by using exclude patterns directly with git-format-staged
(e.g. "!Pods/*"
) but a solution directly in SwiftFormat would be ideal.
@palle-k with git-format-staged
are you using the --stdinpath
argument? I recently updated the docs to recommend this, as it is required for exclusions to work correctly:
git-format-staged --formatter "swiftformat stdin --stdinpath '{}'" "*.swift"
(the reason for this is that git-format-staged
passes files via stdin instead of passing the file path itself, so without the --stdinpath
argument, swiftformat cannot know what the path of the input was, and whether to exclude it)
Yes I am. My git hook currently looks like this (minus the git-format-staged
exclude workaround):
#!/bin/bash
export PATH=/usr/local/bin:$PATH
git-format-staged --formatter "swiftformat stdin --stdinpath '{}' --config path/to/.swiftformat" "*.swift"
My .swiftformat
file contains the following:
--exclude Pods
# and some more commands
and the Pods directory is in the same directory as the .swiftformat
file. And everything works as expected if I simply run swiftformat --config .swiftformat ./
@nicklockwood can you try it without the --config path/to/.swiftformat
? It should pick that up anyway if it's in the same directory.
The Pods directory is getting formatted even without the --config
argument. And according to the output of swiftformat, the .swiftformat file is picked up.
This is not working with the current version 0.48.1. Is it possible to open this issue again? Or another way to make it visible this could need a fix? @nicklockwood
@oonoo which version is workable do you know?
@nicklockwood any updates for this issues?
@keithcml sorry, I forgot about this. AFAICT there's no way to bump reopened issues to the front page of the github issues, so I've opened a new issue for this. Please post any further comments there.
@keithcml @oonoo @palle-k fixed in 0.48.3, sorry for the delay
That's the issue we faced recently.
We have configuration file with exclude option:
If you run swiftformat for root folder like that:
files in Generated folder will be ignored correctly.
But, if you run it for specific file, like we do in githook for all staged files:
This file will be formatted.
After investigation we found that issue was introduced in version
0.36.0
. Version0.35.10
will sayerror: no eligible files found at .../SomeFolder/Generated/SomeFile.swift
but will not format this file.@nicklockwood please, review that change, probably it's the reason https://github.com/nicklockwood/SwiftFormat/commit/10cafc4af83b596dbf7ee932d421d68b15006e5e