mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-08-04 21:52:54 +02:00
ignore: support .jj
as well as .git
This makes it so the presence of `.jj` will cause ripgrep to treat it as a VCS directory, just as if `.git` were present. This is useful for ripgrep's default behavior when working with jj repositories that don't have a `.git` but do have `.gitignore`. Namely, ripgrep requires the presence of a VCS repository in order to respect `.gitignore`. We don't handle clone-specific exclude rules for jj repositories without `.git` though. It seems it isn't 100% set yet where we can find those[1]. Closes #2842 [1]: https://github.com/BurntSushi/ripgrep/pull/2842#discussion_r2020076722
This commit is contained in:
committed by
Andrew Gallant
parent
ff8afcf8aa
commit
bd8a7ae793
@ -20,6 +20,8 @@ Feature enhancements:
|
||||
Completions for the fish shell take ripgrep's config file into account.
|
||||
* [FEATURE #2841](https://github.com/BurntSushi/ripgrep/pull/2841):
|
||||
Add `italic` to the list of available style attributes in `--color`.
|
||||
* [FEATURE #2842](https://github.com/BurntSushi/ripgrep/pull/2842):
|
||||
Directories containing `.jj` are now treated as git repositories.
|
||||
|
||||
|
||||
14.1.1 (2024-09-08)
|
||||
|
@ -212,7 +212,7 @@ impl Ignore {
|
||||
igtmp.absolute_base = Some(absolute_base.clone());
|
||||
igtmp.has_git =
|
||||
if self.0.opts.require_git && self.0.opts.git_ignore {
|
||||
parent.join(".git").exists()
|
||||
parent.join(".git").exists() || parent.join(".jj").exists()
|
||||
} else {
|
||||
false
|
||||
};
|
||||
@ -251,7 +251,7 @@ impl Ignore {
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let has_git = git_type.map(|_| true).unwrap_or(false);
|
||||
let has_git = git_type.is_some() || dir.join(".jj").exists();
|
||||
|
||||
let mut errs = PartialErrorBuilder::default();
|
||||
let custom_ig_matcher = if self.0.custom_ignore_filenames.is_empty() {
|
||||
@ -290,6 +290,7 @@ impl Ignore {
|
||||
errs.maybe_push(err);
|
||||
m
|
||||
};
|
||||
|
||||
let gi_exclude_matcher = if !self.0.opts.git_exclude {
|
||||
Gitignore::empty()
|
||||
} else {
|
||||
@ -954,6 +955,19 @@ mod tests {
|
||||
assert!(ig.matched("baz", false).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gitignore_with_jj() {
|
||||
let td = tmpdir();
|
||||
mkdirp(td.path().join(".jj"));
|
||||
wfile(td.path().join(".gitignore"), "foo\n!bar");
|
||||
|
||||
let (ig, err) = IgnoreBuilder::new().build().add_child(td.path());
|
||||
assert!(err.is_none());
|
||||
assert!(ig.matched("foo", false).is_ignore());
|
||||
assert!(ig.matched("bar", false).is_whitelist());
|
||||
assert!(ig.matched("baz", false).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gitignore_no_git() {
|
||||
let td = tmpdir();
|
||||
|
Reference in New Issue
Block a user