-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ignore] Add extensive test for gitignore matching (#551)
[ignore] tests and new matched_path_or_any_parents method The test data (gitignore rules and expected result) is based on the test repo at <https://github.com/behnam/gitignore-test>. The new `matched_path_or_any_parents` method fixes a bug in gitignore matching where rules of form `<dir>/*` result in ignoring only first-level files, but no deep files. This is not correct, as `<dir>/*` matches the first-level directories under `<dir>`, resulting all to be ignored. The new method fixes it by trying to match all parents in the path against the gitignore rules. The new method is necessary because it necessarily entails a performance hit for trying to match all parents.
- Loading branch information
1 parent
aeac853
commit 84f4b4e
Showing
5 changed files
with
524 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
216 changes: 216 additions & 0 deletions
216
ignore/tests/gitignore_matched_path_or_any_parents_tests.gitignore
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
# Based on https://github.com/behnam/gitignore-test/blob/master/.gitignore | ||
|
||
### file in root | ||
|
||
# MATCH /file_root_1 | ||
file_root_00 | ||
|
||
# NO_MATCH | ||
file_root_01/ | ||
|
||
# NO_MATCH | ||
file_root_02/* | ||
|
||
# NO_MATCH | ||
file_root_03/** | ||
|
||
|
||
# MATCH /file_root_10 | ||
/file_root_10 | ||
|
||
# NO_MATCH | ||
/file_root_11/ | ||
|
||
# NO_MATCH | ||
/file_root_12/* | ||
|
||
# NO_MATCH | ||
/file_root_13/** | ||
|
||
|
||
# NO_MATCH | ||
*/file_root_20 | ||
|
||
# NO_MATCH | ||
*/file_root_21/ | ||
|
||
# NO_MATCH | ||
*/file_root_22/* | ||
|
||
# NO_MATCH | ||
*/file_root_23/** | ||
|
||
|
||
# MATCH /file_root_30 | ||
**/file_root_30 | ||
|
||
# NO_MATCH | ||
**/file_root_31/ | ||
|
||
# NO_MATCH | ||
**/file_root_32/* | ||
|
||
# NO_MATCH | ||
**/file_root_33/** | ||
|
||
|
||
### file in sub-dir | ||
|
||
# MATCH /parent_dir/file_deep_1 | ||
file_deep_00 | ||
|
||
# NO_MATCH | ||
file_deep_01/ | ||
|
||
# NO_MATCH | ||
file_deep_02/* | ||
|
||
# NO_MATCH | ||
file_deep_03/** | ||
|
||
|
||
# NO_MATCH | ||
/file_deep_10 | ||
|
||
# NO_MATCH | ||
/file_deep_11/ | ||
|
||
# NO_MATCH | ||
/file_deep_12/* | ||
|
||
# NO_MATCH | ||
/file_deep_13/** | ||
|
||
|
||
# MATCH /parent_dir/file_deep_20 | ||
*/file_deep_20 | ||
|
||
# NO_MATCH | ||
*/file_deep_21/ | ||
|
||
# NO_MATCH | ||
*/file_deep_22/* | ||
|
||
# NO_MATCH | ||
*/file_deep_23/** | ||
|
||
|
||
# MATCH /parent_dir/file_deep_30 | ||
**/file_deep_30 | ||
|
||
# NO_MATCH | ||
**/file_deep_31/ | ||
|
||
# NO_MATCH | ||
**/file_deep_32/* | ||
|
||
# NO_MATCH | ||
**/file_deep_33/** | ||
|
||
|
||
### dir in root | ||
|
||
# MATCH /dir_root_00 | ||
dir_root_00 | ||
|
||
# MATCH /dir_root_01 | ||
dir_root_01/ | ||
|
||
# MATCH /dir_root_02 | ||
dir_root_02/* | ||
|
||
# MATCH /dir_root_03 | ||
dir_root_03/** | ||
|
||
|
||
# MATCH /dir_root_10 | ||
/dir_root_10 | ||
|
||
# MATCH /dir_root_11 | ||
/dir_root_11/ | ||
|
||
# MATCH /dir_root_12 | ||
/dir_root_12/* | ||
|
||
# MATCH /dir_root_13 | ||
/dir_root_13/** | ||
|
||
|
||
# NO_MATCH | ||
*/dir_root_20 | ||
|
||
# NO_MATCH | ||
*/dir_root_21/ | ||
|
||
# NO_MATCH | ||
*/dir_root_22/* | ||
|
||
# NO_MATCH | ||
*/dir_root_23/** | ||
|
||
|
||
# MATCH /dir_root_30 | ||
**/dir_root_30 | ||
|
||
# MATCH /dir_root_31 | ||
**/dir_root_31/ | ||
|
||
# MATCH /dir_root_32 | ||
**/dir_root_32/* | ||
|
||
# MATCH /dir_root_33 | ||
**/dir_root_33/** | ||
|
||
|
||
### dir in sub-dir | ||
|
||
# MATCH /parent_dir/dir_deep_00 | ||
dir_deep_00 | ||
|
||
# MATCH /parent_dir/dir_deep_01 | ||
dir_deep_01/ | ||
|
||
# NO_MATCH | ||
dir_deep_02/* | ||
|
||
# NO_MATCH | ||
dir_deep_03/** | ||
|
||
|
||
# NO_MATCH | ||
/dir_deep_10 | ||
|
||
# NO_MATCH | ||
/dir_deep_11/ | ||
|
||
# NO_MATCH | ||
/dir_deep_12/* | ||
|
||
# NO_MATCH | ||
/dir_deep_13/** | ||
|
||
|
||
# MATCH /parent_dir/dir_deep_20 | ||
*/dir_deep_20 | ||
|
||
# MATCH /parent_dir/dir_deep_21 | ||
*/dir_deep_21/ | ||
|
||
# MATCH /parent_dir/dir_deep_22 | ||
*/dir_deep_22/* | ||
|
||
# MATCH /parent_dir/dir_deep_23 | ||
*/dir_deep_23/** | ||
|
||
|
||
# MATCH /parent_dir/dir_deep_30 | ||
**/dir_deep_30 | ||
|
||
# MATCH /parent_dir/dir_deep_31 | ||
**/dir_deep_31/ | ||
|
||
# MATCH /parent_dir/dir_deep_32 | ||
**/dir_deep_32/* | ||
|
||
# MATCH /parent_dir/dir_deep_33 | ||
**/dir_deep_33/** |
Oops, something went wrong.