From: Richard Si <63936253+ichard26@users.noreply.github.com> Date: Thu, 13 Aug 2020 03:07:19 +0000 (-0400) Subject: Make --exclude only apply to recursively found files (#1591) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/97c11f22aaf3eacad42d4f78309ffc1f6965e955?hp=97c11f22aaf3eacad42d4f78309ffc1f6965e955 Make --exclude only apply to recursively found files (#1591) Ever since --force-exclude was added, --exclude started to touch files that were given to Black through the CLI too. This is not documented behaviour and neither expected as --exclude and --force-exclude now behave the same! Before this commit, get_sources() when encountering a file that was passed explicitly through the CLI would pass a single Path object list to gen_python_files(). This causes bad behaviour since that function doesn't treat the exclude and force_exclude regexes differently. Which is fine for recursively found files, but *not* for files given through the CLI. Now when get_sources() iterates through srcs and encounters a file, it checks if the force_exclude regex matches, if not, then the file will be added to the computed sources set. A new function had to be created since before you can do regex matching, the path must be normalized. The full process of normalizing the path is somewhat long as there is special error handling. I didn't want to duplicate this logic in get_sources() and gen_python_files() so that's why there is a new helper function. ---