apply patch from upstream

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
epel9
Igor Gnatenko 7 years ago
parent 908c64c9d1
commit 806ac6a306
No known key found for this signature in database
GPG Key ID: 695714BD1BBC5F4C

@ -0,0 +1,47 @@
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

@ -0,0 +1,191 @@
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

@ -0,0 +1,25 @@
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,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 <ignatenkobrain@fedoraproject.org> - 0.4.3-2
- Apply panic from upstream
* Sun Jul 29 2018 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 0.4.3-1
- Update to 0.4.3

@ -0,0 +1,5 @@
---
standard-inventory-qcow2:
qemu:
# `cargo test` usually eats more than 1G.
m: 4G

@ -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
Loading…
Cancel
Save