Repository navigation
Fix negated ignore patterns making jscodeshift ignore every file (#342) - #754
Open
Thanatos9404 wants to merge 1 commit into
Open
Thanatos9404 wants to merge 1 commit into
Thanatos9404 wants to merge 1 commit into
Conversation
A pattern that starts with `!`, such as `!.jenkins/` in a file passed to --ignore-config, was handed to picomatch unchanged. picomatch reads a leading `!` as "anything except", so the pattern matched almost every path and jscodeshift skipped all files. Keep each added pattern as an ordered rule that records whether it was negated, and let the last rule that matches a path decide whether the path is ignored, as .gitignore does. A negated pattern now re-includes paths ignored by an earlier pattern and has no effect on its own. A negated directory such as `!.jenkins/` re-includes only the directory, so the paths inside it are still checked against the other patterns. `\!foo` still matches a literal `!foo`, and `!!foo` re-includes it. Fixes meta#342.
π¦ Changeset detectedLatest commit: ccef579 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@Thanatos9404 is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A line starting with
!in an ignore file, like!.jenkins/in the.eslintignorefrom the issue, made jscodeshift skip every file.addIgnorePatternpassed it to picomatch as is, and picomatch reads a leading!as "anything except".Each pattern now remembers whether it was negated, and
shouldIgnorelets the last matching pattern decide, like.gitignore. So a lone negated pattern no longer ignores anything,!keep.jsafter*.jsbringskeep.jsback, and ignore files without!lines behave exactly as before. As in git, a negation can't bring back files inside a directory that is already ignored.One case still differs from git: if an earlier directory pattern also covers the negated directory (
.*/then!.jenkins/), files inside it stay ignored. I can handle that here or in a follow-up.Thanks to @rootkiller6788 for the earlier attempt in #736. This version keeps the patterns in order, so a later pattern can still override an earlier negation.
Tests: new cases in
src/__tests__/ignoreFiles-test.js. Eight of them fail onmainand all pass with this change. A patch changeset is included.Fixes #342