diff options
author | Andrew Gallant <jamslam@gmail.com> | 2018-04-23 18:33:25 -0400 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2018-04-23 18:33:25 -0400 |
commit | 507801c1f2efdc45ea25227a613c2e38cdecf88b (patch) | |
tree | 95e09935d274c9eebbf75b6c27c2264e7ec7d258 /tests | |
parent | 2a9d0072614da690d8aad77a4c6a39995595af18 (diff) |
ignore: support .git directory OR file
This improves support for submodules, which seem to use a '.git' file
instead of a '.git' directory to indicate a worktree.
Fixes #893
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tests.rs | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/tests/tests.rs b/tests/tests.rs index 855f2484..cab1f42d 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -651,7 +651,7 @@ sherlock!(ignore_git_parent_stop, "Sherlock", ".", // // .gitignore (contains `sherlock`) // foo/ - // .git + // .git/ // bar/ // sherlock // @@ -674,6 +674,39 @@ sherlock:be, to a very large extent, the result of luck. Sherlock Holmes assert_eq!(lines, expected); }); +// Like ignore_git_parent_stop, but with a .git file instead of a .git +// directory. +sherlock!(ignore_git_parent_stop_file, "Sherlock", ".", +|wd: WorkDir, mut cmd: Command| { + // This tests that searching parent directories for .gitignore files stops + // after it sees a .git *file*. A .git file is used for submodules. To test + // this, we create this directory hierarchy: + // + // .gitignore (contains `sherlock`) + // foo/ + // .git + // bar/ + // sherlock + // + // And we perform the search inside `foo/bar/`. ripgrep will stop looking + // for .gitignore files after it sees `foo/.git`, and therefore not + // respect the top-level `.gitignore` containing `sherlock`. + wd.remove("sherlock"); + wd.create(".gitignore", "sherlock\n"); + wd.create_dir("foo"); + wd.create("foo/.git", ""); + wd.create_dir("foo/bar"); + wd.create("foo/bar/sherlock", hay::SHERLOCK); + cmd.current_dir(wd.path().join("foo").join("bar")); + + let lines: String = wd.stdout(&mut cmd); + let expected = "\ +sherlock:For the Doctor Watsons of this world, as opposed to the Sherlock +sherlock:be, to a very large extent, the result of luck. Sherlock Holmes +"; + assert_eq!(lines, expected); +}); + sherlock!(ignore_ripgrep_parent_no_stop, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| { // This is like the `ignore_git_parent_stop` test, except it checks that |