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

Respect --force-exclude for files passed via stdin #1342

merged 2 commits into from Dec 22, 2022


Copy link

@charliermarsh charliermarsh commented Dec 22, 2022

Resolves #1339.

Copy link
Owner Author

It turns out that it's very, very hard to use the ignore crate to answer the question, "Is a given path ignored?", because it doesn't seem to expose the underlying matchers, only the directory walkers. This creates a few problems. I'll just leave this comment here for posterity as I roll back some of the code:

// Step 2: Is the file ignored via a gitignore?
// Note that we can't enforce this behavior for non-existent files, which _could_ come up when
// you pass a file via `--stdin-filename`, and _could_ be considered incorrect. For example,
// if `subdir` is listed in the `gitignore`, and you pass `subdir/`, then
// right now, we _wouldn't_ mark that theoretical file as ignored. If the `ignore` crate had
// a public matcher API, we could support that, but right now, we _have_ to look at the
// filesystem to reverse-engineer the gitignore match.
// TODO(charlie): This isn't right either, because the _parent_ could be the thing that's
// ignored via the `.gitignore`.

Copy link

Seems like I was too slow. Also closes #1343

Copy link
Owner Author

Sadly this doesn't respect gitignore rules in those cases (I tried to get this to work for a while, but I don't think it's reliable without changes to the ignore crate), but otherwise seems to work.

@charliermarsh charliermarsh merged commit 3ac5a9a into main Dec 22, 2022
5 checks passed
@charliermarsh charliermarsh deleted the charlie/stdin-force-exclude branch December 22, 2022 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

Exclude option ignored when directly calling dir/file
2 participants