Skip to content

Commit 08d33d9

Browse files
authored
fix(runner): ignore changes inside .git (#115)
### TL;DR Ignore `.git` directory when tracking file accesses for task caching. ### What changed? Added a condition in `execute_task` to ignore file accesses to paths that start with `.git` or exactly match `.git`. This prevents oxlint's reads inside the `.git` directory from invalidating the cache. Added a test case to verify that changes inside the `.git` directory don't invalidate the lint cache.
1 parent 9a0dbe4 commit 08d33d9

4 files changed

Lines changed: 30 additions & 0 deletions

File tree

crates/vite_task/src/execute.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,10 @@ pub async fn execute_task(
394394
// ignore accesses outside the workspace
395395
continue;
396396
};
397+
if relative_path.as_path().strip_prefix(".git").is_ok() {
398+
// temp workaround for oxlint reading inside .git
399+
continue;
400+
}
397401
match access.mode {
398402
AccessMode::Read => {
399403
path_reads.entry(relative_path).or_insert(PathRead { read_dir_entries: false });
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
> mkdir .git
2+
3+
> vite-plus lint
4+
Cache not found
5+
Found 0 warnings and 0 errors.
6+
Finished in <variable>ms on 0 files with <variable> rules using <variable> threads.
7+
8+
> echo hello > .git/foo.txt
9+
10+
> vite-plus lint # changes inside .git should not invalidate cache
11+
Cache hit, replaying
12+
Found 0 warnings and 0 errors.
13+
Finished in <variable>ms on 0 files with <variable> rules using <variable> threads.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"env": {
3+
"VITE_DISABLE_AUTO_INSTALL": "1"
4+
},
5+
"commands": [
6+
"mkdir .git",
7+
"vite-plus lint",
8+
"echo hello > .git/foo.txt",
9+
"vite-plus lint # changes inside .git should not invalidate cache"
10+
]
11+
}

0 commit comments

Comments
 (0)