Cache - excluding files or folders with ! not working
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
Excluding a file or folder does not work as expected with caching. For example,
~/cache
!~/cache/subfolder
is matching:
../../../cache
I think this is because caching uses implicitDescendants: false. Since we're not traversing any descendants, the negation pattern does not match anything.
One option is to just set implicitDescendants: true, but this may add inefficiencies as we will need to enumerate all the files and generate a large "includes file" for tar. We essentially need it to scan the descendants but stop whenever the entire folder is included. For example, the following files:
~/cache/foo.txt
~/cache/bar.txt
~/cache/src/main.c
~/cache/src/lib/baz.dll
~/cache/bin/main.exe
with the glob patterns of ~/cache and !~/cache/bin should produce the list:
~/cache/foo.txt
~/cache/bar.txt
~/cache/src
To Reproduce
See https://github.com/dhadka/cache-test-exclusion
Expected behavior
Negated files / folders are excluded from the cache.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/cache/src/internal/cacheUtils.ts, especially the implicitDescendants setting referenced in the issue, and reproduce the behavior with the linked cache-test-exclusion repository. Trace how the glob patterns /cache and !/cache/bin are converted into the tar includes list. Done means negated files and folders are excluded without unnecessarily enumerating every descendant.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100