Drop globset::list_from_ignore_file

This commit is contained in:
Félix Saparelli 2022-01-16 15:21:10 +13:00
parent 817f4c2caf
commit 561a34d90e
No known key found for this signature in database
GPG key ID: B948C4BAE44FC474

View file

@ -4,7 +4,6 @@ use std::ffi::OsString;
use std::path::{Path, PathBuf};
use ignore::gitignore::{Gitignore, GitignoreBuilder};
use tokio::fs::read_to_string;
use tracing::{debug, trace, trace_span};
use crate::error::RuntimeError;
@ -86,25 +85,6 @@ impl GlobsetFilterer {
extensions,
})
}
/// Produces a list of ignore patterns compatible with [`new`][GlobsetFilterer::new()] from an [`IgnoreFile`].
pub async fn list_from_ignore_file(
ig: &IgnoreFile,
) -> Result<Vec<(String, Option<PathBuf>)>, RuntimeError> {
let content = read_to_string(&ig.path).await?;
let lines = content.lines();
let mut ignores = Vec::with_capacity(lines.size_hint().0);
for line in lines {
if line.is_empty() || line.starts_with('#') {
continue;
}
ignores.push((line.to_owned(), ig.applies_in.clone()));
}
Ok(ignores)
}
}
impl Filterer for GlobsetFilterer {