turbo icon indicating copy to clipboard operation
turbo copied to clipboard

Incompatibility with gitignore spec

Open robations opened this issue 2 years ago • 0 comments

What version of Turborepo are you using?

1.3.1

What package manager are you using / does the bug impact?

pnpm

What operating system are you using?

Mac

Describe the Bug

I was debugging an issue where running "test" across the repo was always a cache miss.

All files changed by tests (find . -type f -mmin -2) were excluded by git (node_modules, test coverage output, turbo caches).

On a hunch I changed an ignore pattern in a workspace package:

# /packages/foo/.gitignore

## from
/coverage

## to
coverage

And now I'm getting consistent hashes for the build and cache hits.

/coverage is important in gitignore for matching specific paths as opposed to any directory, say, /coverage but not /src/coverage so I'd consider my change as a workaround rather than a fix.

Expected Behavior

The following ignore rule should exclude /packages/foo/coverage from the cache hash algorithm.

# /packages/foo/.gitignore
/coverage

See the git docs, especially this point:

If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular .gitignore file itself. Otherwise the pattern may also match at any level below the .gitignore level.

To Reproduce

Check out the proof-of-concept here:

https://github.com/robations/turbo-vs-ignore

(assumes you have the pnpm exec available)

Thanks for reading!

robations avatar Jul 01 '22 16:07 robations