parent
806ac6a306
commit
a415e6e14a
@ -1,47 +0,0 @@
|
||||
From 0863c75a5a819dc94754f3465246366ffd5d541f Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Gallant <jamslam@gmail.com>
|
||||
Date: Sun, 29 Jul 2018 08:30:53 -0400
|
||||
Subject: [PATCH 1/3] ignore: fix bug in matched_path_or_any_parents
|
||||
|
||||
This method was supposed to panic whenever the given path wasn't under
|
||||
the root of the gitignore patcher. Instead of using assert!, it was using
|
||||
debug_assert!. This actually caused tests to fail when running under
|
||||
release mode, because the debug_assert! wouldn't trip.
|
||||
|
||||
Fixes #671
|
||||
---
|
||||
ignore/src/gitignore.rs | 11 +++++++----
|
||||
1 file changed, 7 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/ignore/src/gitignore.rs b/ignore/src/gitignore.rs
|
||||
index 2a3016b..d661c84 100644
|
||||
--- a/ignore/src/gitignore.rs
|
||||
+++ b/ignore/src/gitignore.rs
|
||||
@@ -220,6 +220,11 @@ impl Gitignore {
|
||||
/// determined by a common suffix of the directory containing this
|
||||
/// gitignore) is stripped. If there is no common suffix/prefix overlap,
|
||||
/// then `path` is assumed to be relative to this matcher.
|
||||
+ ///
|
||||
+ /// # Panics
|
||||
+ ///
|
||||
+ /// This method panics if the given file path is not under the root path
|
||||
+ /// of this matcher.
|
||||
pub fn matched_path_or_any_parents<P: AsRef<Path>>(
|
||||
&self,
|
||||
path: P,
|
||||
@@ -229,10 +234,8 @@ impl Gitignore {
|
||||
return Match::None;
|
||||
}
|
||||
let mut path = self.strip(path.as_ref());
|
||||
- debug_assert!(
|
||||
- !path.has_root(),
|
||||
- "path is expect to be under the root"
|
||||
- );
|
||||
+ assert!(!path.has_root(), "path is expect to be under the root");
|
||||
+
|
||||
match self.matched_stripped(path, is_dir) {
|
||||
Match::None => (), // walk up
|
||||
a_match => return a_match,
|
||||
--
|
||||
2.18.0
|
||||
|
@ -1,191 +0,0 @@
|
||||
From 45473ba48f0561e970596ac979ba5d0bac92242a Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Gallant <jamslam@gmail.com>
|
||||
Date: Sun, 29 Jul 2018 08:31:04 -0400
|
||||
Subject: [PATCH 2/3] ignore/style: 80 columns, dammit
|
||||
|
||||
---
|
||||
...gnore_matched_path_or_any_parents_tests.rs | 80 ++++++++++++-------
|
||||
1 file changed, 53 insertions(+), 27 deletions(-)
|
||||
|
||||
diff --git a/ignore/tests/gitignore_matched_path_or_any_parents_tests.rs b/ignore/tests/gitignore_matched_path_or_any_parents_tests.rs
|
||||
index 4de7cf3..28d8e2f 100644
|
||||
--- a/ignore/tests/gitignore_matched_path_or_any_parents_tests.rs
|
||||
+++ b/ignore/tests/gitignore_matched_path_or_any_parents_tests.rs
|
||||
@@ -1,13 +1,11 @@
|
||||
extern crate ignore;
|
||||
|
||||
-
|
||||
use std::path::Path;
|
||||
|
||||
use ignore::gitignore::{Gitignore, GitignoreBuilder};
|
||||
|
||||
-
|
||||
-const IGNORE_FILE: &'static str = "tests/gitignore_matched_path_or_any_parents_tests.gitignore";
|
||||
-
|
||||
+const IGNORE_FILE: &'static str =
|
||||
+ "tests/gitignore_matched_path_or_any_parents_tests.gitignore";
|
||||
|
||||
fn get_gitignore() -> Gitignore {
|
||||
let mut builder = GitignoreBuilder::new("ROOT");
|
||||
@@ -16,9 +14,8 @@ fn get_gitignore() -> Gitignore {
|
||||
builder.build().unwrap()
|
||||
}
|
||||
|
||||
-
|
||||
#[test]
|
||||
-#[should_panic(expected = "path is expect to be under the root")]
|
||||
+#[should_panic(expected = "path is expected to be under the root")]
|
||||
fn test_path_should_be_under_root() {
|
||||
let gitignore = get_gitignore();
|
||||
let path = "/tmp/some_file";
|
||||
@@ -26,11 +23,12 @@ fn test_path_should_be_under_root() {
|
||||
assert!(false);
|
||||
}
|
||||
|
||||
-
|
||||
#[test]
|
||||
fn test_files_in_root() {
|
||||
let gitignore = get_gitignore();
|
||||
- let m = |path: &str| gitignore.matched_path_or_any_parents(Path::new(path), false);
|
||||
+ let m = |path: &str| {
|
||||
+ gitignore.matched_path_or_any_parents(Path::new(path), false)
|
||||
+ };
|
||||
|
||||
// 0x
|
||||
assert!(m("ROOT/file_root_00").is_ignore());
|
||||
@@ -61,7 +59,9 @@ fn test_files_in_root() {
|
||||
#[test]
|
||||
fn test_files_in_deep() {
|
||||
let gitignore = get_gitignore();
|
||||
- let m = |path: &str| gitignore.matched_path_or_any_parents(Path::new(path), false);
|
||||
+ let m = |path: &str| {
|
||||
+ gitignore.matched_path_or_any_parents(Path::new(path), false)
|
||||
+ };
|
||||
|
||||
// 0x
|
||||
assert!(m("ROOT/parent_dir/file_deep_00").is_ignore());
|
||||
@@ -92,8 +92,9 @@ fn test_files_in_deep() {
|
||||
#[test]
|
||||
fn test_dirs_in_root() {
|
||||
let gitignore = get_gitignore();
|
||||
- let m =
|
||||
- |path: &str, is_dir: bool| gitignore.matched_path_or_any_parents(Path::new(path), is_dir);
|
||||
+ let m = |path: &str, is_dir: bool| {
|
||||
+ gitignore.matched_path_or_any_parents(Path::new(path), is_dir)
|
||||
+ };
|
||||
|
||||
// 00
|
||||
assert!(m("ROOT/dir_root_00", true).is_ignore());
|
||||
@@ -196,20 +197,25 @@ fn test_dirs_in_root() {
|
||||
#[test]
|
||||
fn test_dirs_in_deep() {
|
||||
let gitignore = get_gitignore();
|
||||
- let m =
|
||||
- |path: &str, is_dir: bool| gitignore.matched_path_or_any_parents(Path::new(path), is_dir);
|
||||
+ let m = |path: &str, is_dir: bool| {
|
||||
+ gitignore.matched_path_or_any_parents(Path::new(path), is_dir)
|
||||
+ };
|
||||
|
||||
// 00
|
||||
assert!(m("ROOT/parent_dir/dir_deep_00", true).is_ignore());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_00/file", false).is_ignore());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_00/child_dir", true).is_ignore());
|
||||
- assert!(m("ROOT/parent_dir/dir_deep_00/child_dir/file", false).is_ignore());
|
||||
+ assert!(
|
||||
+ m("ROOT/parent_dir/dir_deep_00/child_dir/file", false).is_ignore()
|
||||
+ );
|
||||
|
||||
// 01
|
||||
assert!(m("ROOT/parent_dir/dir_deep_01", true).is_ignore());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_01/file", false).is_ignore());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_01/child_dir", true).is_ignore());
|
||||
- assert!(m("ROOT/parent_dir/dir_deep_01/child_dir/file", false).is_ignore());
|
||||
+ assert!(
|
||||
+ m("ROOT/parent_dir/dir_deep_01/child_dir/file", false).is_ignore()
|
||||
+ );
|
||||
|
||||
// 02
|
||||
assert!(m("ROOT/parent_dir/dir_deep_02", true).is_none());
|
||||
@@ -251,47 +257,67 @@ fn test_dirs_in_deep() {
|
||||
assert!(m("ROOT/parent_dir/dir_deep_20", true).is_ignore());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_20/file", false).is_ignore());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_20/child_dir", true).is_ignore());
|
||||
- assert!(m("ROOT/parent_dir/dir_deep_20/child_dir/file", false).is_ignore());
|
||||
+ assert!(
|
||||
+ m("ROOT/parent_dir/dir_deep_20/child_dir/file", false).is_ignore()
|
||||
+ );
|
||||
|
||||
// 21
|
||||
assert!(m("ROOT/parent_dir/dir_deep_21", true).is_ignore());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_21/file", false).is_ignore());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_21/child_dir", true).is_ignore());
|
||||
- assert!(m("ROOT/parent_dir/dir_deep_21/child_dir/file", false).is_ignore());
|
||||
+ assert!(
|
||||
+ m("ROOT/parent_dir/dir_deep_21/child_dir/file", false).is_ignore()
|
||||
+ );
|
||||
|
||||
// 22
|
||||
- assert!(m("ROOT/parent_dir/dir_deep_22", true).is_none()); // dir itself doesn't match
|
||||
+ // dir itself doesn't match
|
||||
+ assert!(m("ROOT/parent_dir/dir_deep_22", true).is_none());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_22/file", false).is_ignore());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_22/child_dir", true).is_ignore());
|
||||
- assert!(m("ROOT/parent_dir/dir_deep_22/child_dir/file", false).is_ignore());
|
||||
+ assert!(
|
||||
+ m("ROOT/parent_dir/dir_deep_22/child_dir/file", false).is_ignore()
|
||||
+ );
|
||||
|
||||
// 23
|
||||
- assert!(m("ROOT/parent_dir/dir_deep_23", true).is_none()); // dir itself doesn't match
|
||||
+ // dir itself doesn't match
|
||||
+ assert!(m("ROOT/parent_dir/dir_deep_23", true).is_none());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_23/file", false).is_ignore());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_23/child_dir", true).is_ignore());
|
||||
- assert!(m("ROOT/parent_dir/dir_deep_23/child_dir/file", false).is_ignore());
|
||||
+ assert!(
|
||||
+ m("ROOT/parent_dir/dir_deep_23/child_dir/file", false).is_ignore()
|
||||
+ );
|
||||
|
||||
// 30
|
||||
assert!(m("ROOT/parent_dir/dir_deep_30", true).is_ignore());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_30/file", false).is_ignore());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_30/child_dir", true).is_ignore());
|
||||
- assert!(m("ROOT/parent_dir/dir_deep_30/child_dir/file", false).is_ignore());
|
||||
+ assert!(
|
||||
+ m("ROOT/parent_dir/dir_deep_30/child_dir/file", false).is_ignore()
|
||||
+ );
|
||||
|
||||
// 31
|
||||
assert!(m("ROOT/parent_dir/dir_deep_31", true).is_ignore());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_31/file", false).is_ignore());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_31/child_dir", true).is_ignore());
|
||||
- assert!(m("ROOT/parent_dir/dir_deep_31/child_dir/file", false).is_ignore());
|
||||
+ assert!(
|
||||
+ m("ROOT/parent_dir/dir_deep_31/child_dir/file", false).is_ignore()
|
||||
+ );
|
||||
|
||||
// 32
|
||||
- assert!(m("ROOT/parent_dir/dir_deep_32", true).is_none()); // dir itself doesn't match
|
||||
+ // dir itself doesn't match
|
||||
+ assert!(m("ROOT/parent_dir/dir_deep_32", true).is_none());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_32/file", false).is_ignore());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_32/child_dir", true).is_ignore());
|
||||
- assert!(m("ROOT/parent_dir/dir_deep_32/child_dir/file", false).is_ignore());
|
||||
+ assert!(
|
||||
+ m("ROOT/parent_dir/dir_deep_32/child_dir/file", false).is_ignore()
|
||||
+ );
|
||||
|
||||
// 33
|
||||
- assert!(m("ROOT/parent_dir/dir_deep_33", true).is_none()); // dir itself doesn't match
|
||||
+ // dir itself doesn't match
|
||||
+ assert!(m("ROOT/parent_dir/dir_deep_33", true).is_none());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_33/file", false).is_ignore());
|
||||
assert!(m("ROOT/parent_dir/dir_deep_33/child_dir", true).is_ignore());
|
||||
- assert!(m("ROOT/parent_dir/dir_deep_33/child_dir/file", false).is_ignore());
|
||||
+ assert!(
|
||||
+ m("ROOT/parent_dir/dir_deep_33/child_dir/file", false).is_ignore()
|
||||
+ );
|
||||
}
|
||||
--
|
||||
2.18.0
|
||||
|
@ -1,25 +0,0 @@
|
||||
From 651a0f1ddfcb3e37647199863d2ce1d1db3c56af Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Gallant <jamslam@gmail.com>
|
||||
Date: Sun, 29 Jul 2018 08:37:24 -0400
|
||||
Subject: [PATCH 3/3] ignore: fix typo
|
||||
|
||||
---
|
||||
ignore/src/gitignore.rs | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/ignore/src/gitignore.rs b/ignore/src/gitignore.rs
|
||||
index d661c84..15827fd 100644
|
||||
--- a/ignore/src/gitignore.rs
|
||||
+++ b/ignore/src/gitignore.rs
|
||||
@@ -234,7 +234,7 @@ impl Gitignore {
|
||||
return Match::None;
|
||||
}
|
||||
let mut path = self.strip(path.as_ref());
|
||||
- assert!(!path.has_root(), "path is expect to be under the root");
|
||||
+ assert!(!path.has_root(), "path is expected to be under the root");
|
||||
|
||||
match self.matched_stripped(path, is_dir) {
|
||||
Match::None => (), // walk up
|
||||
--
|
||||
2.18.0
|
||||
|
@ -1,9 +0,0 @@
|
||||
--- ignore-0.4.3/Cargo.toml 1970-01-01T01:00:00+01:00
|
||||
+++ ignore-0.4.3/Cargo.toml 2018-07-29T07:38:06.998096+02:00
|
||||
@@ -56,6 +56,3 @@
|
||||
|
||||
[features]
|
||||
simd-accel = ["globset/simd-accel"]
|
||||
-[target."cfg(windows)".dependencies.winapi]
|
||||
-version = "0.3"
|
||||
-features = ["std", "winnt"]
|
@ -0,0 +1,8 @@
|
||||
--- ignore-0.4.4/Cargo.toml 1970-01-01T01:00:00+01:00
|
||||
+++ ignore-0.4.4/Cargo.toml 2018-09-08T23:40:02.288602+02:00
|
||||
@@ -56,5 +56,3 @@
|
||||
|
||||
[features]
|
||||
simd-accel = ["globset/simd-accel"]
|
||||
-[target."cfg(windows)".dependencies.winapi-util]
|
||||
-version = "0.1.1"
|
@ -1 +1 @@
|
||||
SHA512 (ignore-0.4.3.crate) = a4372de85ee945e68c503e743f28621d88e19facd2ec0af5dd2cfccc45c8ad25abc655c16020427a4357bd0c07f48348ccd2d19dc7d6b9046d13fcb33973a06a
|
||||
SHA512 (ignore-0.4.4.crate) = b7dd5de1c14b77483d22235c4738f39123011bc8c19b785fb528d30fbfe9e9c2f8e3b137ad2d3516ce8f59c2ae06bddbe80811423fcc5ef76cb851fa7ad866d9
|
||||
|
Loading…
Reference in new issue