Root exclusions in the server to project root (#16043)

## Summary

fixes: #16041 

## Test Plan

Using the [project](https://github.com/bwcc-clan/polebot) in the linked
issue:

Notice how the project "polebot" is in the "play" directory which is
included in the `exclude` setting as:

```toml
exclude = ["play"]
```

**Before this fix**

```
DEBUG ruff:worker:0 ruff_server::resolve: Ignored path via `exclude`: /private/tmp/ruff-test/play/polebot/src/utils/log_tools.py
```

**After this fix**

```
DEBUG ruff:worker:2 ruff_server::resolve: Included path via `include`: /private/tmp/ruff-test/play/polebot/src/utils/log_tools.py
```

I also updated the same project to remove the "play" directory from the
`exclude` setting and made sure that anything under the `polebot/play`
directory is included:

```
DEBUG  ruff:worker:4 ruff_server::resolve: Included path via `include`: /private/tmp/ruff-test/play/polebot/play/test.py
```

And, excluded when I add the directory back:

```
DEBUG  ruff:worker:2 ruff_server::resolve: Ignored path via `exclude`: /private/tmp/ruff-test/play/polebot/play/test.py
```
This commit is contained in:
Dhruv Manilawala 2025-02-10 10:27:14 +05:30 committed by GitHub
parent cc0a5dd14a
commit 869a9543e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 16 deletions

View file

@ -59,8 +59,7 @@ fn is_document_excluded(
) -> bool {
if let Some(exclusion) = match_any_exclusion(
path,
&resolver_settings.exclude,
&resolver_settings.extend_exclude,
resolver_settings,
linter_settings.map(|s| &*s.exclude),
formatter_settings.map(|s| &*s.exclude),
) {
@ -68,11 +67,7 @@ fn is_document_excluded(
return true;
}
if let Some(inclusion) = match_any_inclusion(
path,
&resolver_settings.include,
&resolver_settings.extend_include,
) {
if let Some(inclusion) = match_any_inclusion(path, resolver_settings) {
tracing::debug!("Included path via `{}`: {}", inclusion, path.display());
false
} else if let Some(LanguageId::Python) = language_id {