Skip to content

fix: respect .gitignore negation patterns when copying project files#3554

Open
PHILLIPS71 wants to merge 2 commits intoexpo:mainfrom
PHILLIPS71:fix/vcs-gitignore-negation-patterns
Open

fix: respect .gitignore negation patterns when copying project files#3554
PHILLIPS71 wants to merge 2 commits intoexpo:mainfrom
PHILLIPS71:fix/vcs-gitignore-negation-patterns

Conversation

@PHILLIPS71
Copy link
Copy Markdown

Why

.gitignore negation patterns (e.g. .eas/* + !.eas/build/) were not being respected when copying project files. Once a file or directory was marked as ignored, there was no way for a negation rule in the same .gitignore to un-ignore it. This also affected .gitignore files inside dot-directories (e.g. .eas/.gitignore), which were never discovered at all.

How

  1. Negation support - switched ignores() from an early-return loop to accumulating state. It now uses ignore.test() instead of ignore.ignores() to get both ignored and unignored signals, so a negation rule in the same .gitignore instance can override an earlier positive rule.

  2. Dot-directory discovery - added dot: true to the fast-glob call that finds .gitignore files, so files like .eas/.gitignore are picked up.

  3. Directory negation patterns - node:fs omits trailing slashes from directory paths, so patterns like !build/ never matched. The filter now calls lstatSync to detect directories and appends a trailing slash before passing the path to ignores(), which correctly distinguishes !build/ (directory) from a file named build.

Test Plan

Automated tests added in packages/eas-cli/src/vcs/__tests__/local-test.ts covering:

  • negation patterns un-ignoring a directory and its contents in the same .gitignore
  • the no-negation baseline still ignoring correctly
  • !build/ not incorrectly un-ignoring a file named build
  • .gitignore files inside dot-directories being picked up

To verify manually, add .eas/* and !.eas/build/ to your project's .gitignore and run a build. The .eas/build/ directory should be included in the uploaded archive.

@github-actions
Copy link
Copy Markdown

Subscribed to pull request

File Patterns Mentions
**/* @douglowder

Generated by CodeMention

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant