From 806ac6a306d0b88fa67fe3a460e0858e059d6d4a Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Sun, 29 Jul 2018 15:28:36 +0200 Subject: [PATCH] apply patch from upstream Signed-off-by: Igor Gnatenko --- ...x-bug-in-matched_path_or_any_parents.patch | 47 +++++ 0002-ignore-style-80-columns-dammit.patch | 191 ++++++++++++++++++ 0003-ignore-fix-typo.patch | 25 +++ rust-ignore.spec | 20 +- tests/.fmf/version | 1 + tests/provision.fmf | 5 + tests/tests.yml | 13 ++ 7 files changed, 297 insertions(+), 5 deletions(-) create mode 100644 0001-ignore-fix-bug-in-matched_path_or_any_parents.patch create mode 100644 0002-ignore-style-80-columns-dammit.patch create mode 100644 0003-ignore-fix-typo.patch create mode 100644 tests/.fmf/version create mode 100644 tests/provision.fmf create mode 100644 tests/tests.yml diff --git a/0001-ignore-fix-bug-in-matched_path_or_any_parents.patch b/0001-ignore-fix-bug-in-matched_path_or_any_parents.patch new file mode 100644 index 0000000..6d19c61 --- /dev/null +++ b/0001-ignore-fix-bug-in-matched_path_or_any_parents.patch @@ -0,0 +1,47 @@ +From 0863c75a5a819dc94754f3465246366ffd5d541f Mon Sep 17 00:00:00 2001 +From: Andrew Gallant +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>( + &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 + diff --git a/0002-ignore-style-80-columns-dammit.patch b/0002-ignore-style-80-columns-dammit.patch new file mode 100644 index 0000000..0274ee0 --- /dev/null +++ b/0002-ignore-style-80-columns-dammit.patch @@ -0,0 +1,191 @@ +From 45473ba48f0561e970596ac979ba5d0bac92242a Mon Sep 17 00:00:00 2001 +From: Andrew Gallant +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 + diff --git a/0003-ignore-fix-typo.patch b/0003-ignore-fix-typo.patch new file mode 100644 index 0000000..9086c08 --- /dev/null +++ b/0003-ignore-fix-typo.patch @@ -0,0 +1,25 @@ +From 651a0f1ddfcb3e37647199863d2ce1d1db3c56af Mon Sep 17 00:00:00 2001 +From: Andrew Gallant +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 + diff --git a/rust-ignore.spec b/rust-ignore.spec index 5af5123..b7e70df 100644 --- a/rust-ignore.spec +++ b/rust-ignore.spec @@ -1,12 +1,13 @@ # Generated by rust2rpm -%bcond_without check +# Tests are run in infrastructure +%bcond_with check %global debug_package %{nil} %global crate ignore Name: rust-%{crate} Version: 0.4.3 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Fast library for efficiently matching ignore files License: Unlicense or MIT @@ -15,6 +16,9 @@ Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{ # Initial patched metadata # * No windows Patch0: ignore-0.4.3-fix-metadata.diff +Patch0001: 0001-ignore-fix-bug-in-matched_path_or_any_parents.patch +Patch0002: 0002-ignore-style-80-columns-dammit.patch +Patch0003: 0003-ignore-fix-typo.patch ExclusiveArch: %{rust_arches} @@ -49,7 +53,11 @@ This package contains library source intended for building other packages which use %{crate} from crates.io. %prep -%autosetup -n %{crate}-%{version} -p1 +%autosetup -n %{crate}-%{version} -N +%patch0 -p1 +%patch1 -p2 +%patch2 -p2 +%patch3 -p2 %cargo_prep %build @@ -60,8 +68,7 @@ which use %{crate} from crates.io. %if %{with check} %check -# https://github.com/BurntSushi/ripgrep/issues/671 -%cargo_test || : +%cargo_test %endif %files devel @@ -70,6 +77,9 @@ which use %{crate} from crates.io. %{cargo_registry}/%{crate}-%{version}/ %changelog +* Sun Jul 29 2018 Igor Gnatenko - 0.4.3-2 +- Apply panic from upstream + * Sun Jul 29 2018 Igor Gnatenko - 0.4.3-1 - Update to 0.4.3 diff --git a/tests/.fmf/version b/tests/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/tests/provision.fmf b/tests/provision.fmf new file mode 100644 index 0000000..503a97c --- /dev/null +++ b/tests/provision.fmf @@ -0,0 +1,5 @@ +--- +standard-inventory-qcow2: + qemu: + # `cargo test` usually eats more than 1G. + m: 4G diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..856b559 --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,13 @@ +--- +- hosts: localhost + roles: + - role: standard-test-basic + tags: + - classic + repositories: + - repo: "https://src.fedoraproject.org/tests/rust.git" + dest: rust + tests: + - rust/cargo-test + environment: + pkg: rust-ignore