diff options
author | Thayne McCombs <astrothayne@gmail.com> | 2024-04-30 00:02:27 -0600 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2024-04-30 15:56:12 +0200 |
commit | 664708501560988052abb7e1791dcdaec6f7e1ef (patch) | |
tree | 9411e2ba590db74e17b1b533813054121437145a | |
parent | 6af8f092ee20f23b4d3cd891be8b77068284d9a8 (diff) |
Add test for gitignore workaround
And make sure it works for user-supplied path of "."
Also add changelog entry
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | src/cli.rs | 3 | ||||
-rw-r--r-- | tests/tests.rs | 13 |
3 files changed, 18 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b84cdb..f21ca26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ ## Bugfixes - Respect NO_COLOR environment variable with `--list-details` option. (#1455) +- Fix bug that would cause hidden files to be includeddespite gitignore rules + if search path is "." (#1461, BurntSushi/ripgrep#2711). ## Changes @@ -665,6 +665,9 @@ impl Opts { fn normalize_path(&self, path: &Path) -> PathBuf { if self.absolute_path { filesystem::absolute_path(path.normalize().unwrap().as_path()).unwrap() + } else if path == Path::new(".") { + // Change "." to "./" as a workaround for https://github.com/BurntSushi/ripgrep/pull/2711 + PathBuf::from("./") } else { path.to_path_buf() } diff --git a/tests/tests.rs b/tests/tests.rs index 071d1f0..1810ecd 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -2599,3 +2599,16 @@ fn test_git_dir() { nested/dir/.git/foo2", ); } + +#[test] +fn test_gitignore_parent() { + let te = TestEnv::new(&["sub"], &[".abc", "sub/.abc"]); + + fs::File::create(te.test_root().join(".gitignore")) + .unwrap() + .write_all(b".abc\n") + .unwrap(); + + te.assert_output_subdirectory("sub", &["--hidden"], ""); + te.assert_output_subdirectory("sub", &["--hidden", "--search-path", "."], ""); +} |