-
-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The pattern in the subdirectory gitignore is not correctly excluded #146
Comments
According to .gitignore spec 2.22.1:
A patch of code that conforms to this specification is as follows: const mapGitIgnorePatternTo = base => ignore => {
+ const isSubLevelMatch = /^[^/]+\/?$/.test(ignore);
+
if (ignore.startsWith('!')) {
+ if (isSubLevelMatch) {
+ return '!' + path.posix.join(base, '**', ignore.slice(1));
+ }
return '!' + path.posix.join(base, ignore.slice(1));
}
+ if (isSubLevelMatch) {
+ return path.posix.join(base, '**', ignore);
+ }
return path.posix.join(base, ignore);
}; |
Is there any progress on this? Lines 18 to 24 in c1a3b32
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
file structure:
./dir/.gitignore
:List of files to be excluded by git:
If globby works correctly, only the
foo.log
file should be output:However,
globby@11.0.1
outputs like this:The file
dir/subdir/baz.log
is not excluded!When
globby@11.0.1
parses the.gitignore
in a subdirectory, it adds the path of the parent to the beginning of each rule:https://github.com/sindresorhus/globby/blob/v11.0.1/gitignore.js#L18-L24
So, internally,
globby@11.0.1
has changed the contents of the./dir/.gitignore
file to look like this:Therefore, you can avoid this problem by modifying the contents of the
./dir/.gitignore
file as follows:However, this writing style is redundant. Most projects will probably be written in the
*.log
style.I believe this is a bug that should be fixed.
The text was updated successfully, but these errors were encountered: