Skip to content

Commit

Permalink
Include file permissions in key for cached files (#5901)
Browse files Browse the repository at this point in the history
Reimplements #3104
Closes #5726

Note that we will generate the hash for a cache key twice in normal
operation. Once to check for the cached item and again to update the
cache. We could optimize this by generating the hash once in
`diagnostics::lint_file` and passing the `u64` into `get` and `update`.
We'd probably want to wrap it in a `CacheKeyHash` enum for type safety.

## Test plan

Unit tests for Windows and Unix.

Manual test with case from issue

```
❯ touch fake.py
❯ chmod +x fake.py
❯ ./target/debug/ruff --select EXE fake.py
fake.py:1:1: EXE002 The file is executable but no shebang is present
Found 1 error.
❯ chmod -x fake.py
❯ ./target/debug/ruff --select EXE fake.py
```
  • Loading branch information
zanieb committed Jul 25, 2023
1 parent cbf6085 commit 3000a47
Show file tree
Hide file tree
Showing 5 changed files with 282 additions and 120 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/ruff_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ruff_python_ast = { path = "../ruff_python_ast" }
ruff_python_formatter = { path = "../ruff_python_formatter" }
ruff_text_size = { workspace = true }
ruff_textwrap = { path = "../ruff_textwrap" }
ruff_macros = { path = "../ruff_macros" }

annotate-snippets = { version = "0.9.1", features = ["color"] }
anyhow = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# NOTE: sync with cache::invalidation test
a = 1

__all__ = list(["a", "b"])

0 comments on commit 3000a47

Please sign in to comment.