forked from rojo-rbx/rojo
Implement glob ignores (#272)
* Add Glob wrapper type with better serialization * Introduce PathIgnoreRule struct * Implement equality for Glob type * Add PathIgnoreRule to InstanceContext * Implement glob ignores in directory middleware * Fix up filters * Use Iterator::all instead of loop * Add project-level configuration for glob ignores * Add test project for glob ignores * Wire up project file and snapshots to make glob ignores work * Better codepaths for adding ignore rules with empty iterators * Add test for globs inherited from parent projects * Add test details, support glob ignores in nested projects * Add feature flag for globs * Switch to use ExactSizeIterator instead of size_hint * Remove glob visitor
This commit is contained in:
committed by
GitHub
parent
ae811aafd0
commit
e261e7a2c7
@@ -26,11 +26,16 @@ impl SnapshotMiddleware for SnapshotDir {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let children: Vec<VfsEntry> = entry.children(vfs)?;
|
||||
let passes_filter_rules = |child: &VfsEntry| {
|
||||
context
|
||||
.path_ignore_rules
|
||||
.iter()
|
||||
.all(|rule| rule.passes(child.path()))
|
||||
};
|
||||
|
||||
let mut snapshot_children = Vec::new();
|
||||
|
||||
for child in children.into_iter() {
|
||||
for child in entry.children(vfs)?.into_iter().filter(passes_filter_rules) {
|
||||
if let Some(child_snapshot) = snapshot_from_vfs(context, vfs, &child)? {
|
||||
snapshot_children.push(child_snapshot);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ use rbx_reflection::try_resolve_value;
|
||||
|
||||
use crate::{
|
||||
project::{Project, ProjectNode},
|
||||
snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot, InstigatingSource},
|
||||
snapshot::{
|
||||
InstanceContext, InstanceMetadata, InstanceSnapshot, InstigatingSource, PathIgnoreRule,
|
||||
},
|
||||
vfs::{FsResultExt, Vfs, VfsEntry, VfsFetcher},
|
||||
};
|
||||
|
||||
@@ -45,10 +47,19 @@ impl SnapshotMiddleware for SnapshotProject {
|
||||
let project = Project::load_from_slice(&entry.contents(vfs)?, entry.path())
|
||||
.map_err(|err| SnapshotError::malformed_project(err, entry.path()))?;
|
||||
|
||||
let mut context = context.clone();
|
||||
|
||||
let rules = project.glob_ignore_paths.iter().map(|glob| PathIgnoreRule {
|
||||
glob: glob.clone(),
|
||||
base_path: project.folder_location().to_path_buf(),
|
||||
});
|
||||
|
||||
context.add_path_ignore_rules(rules);
|
||||
|
||||
// Snapshotting a project should always return an instance, so this
|
||||
// unwrap is safe.
|
||||
let mut snapshot = snapshot_project_node(
|
||||
context,
|
||||
&context,
|
||||
project.folder_location(),
|
||||
&project.name,
|
||||
&project.tree,
|
||||
|
||||
Reference in New Issue
Block a user