Skip to content

Commit fedd5fd

Browse files
committed
feat: add new filter_by_attributes trait method
1 parent 925253e commit fedd5fd

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

  • plumbing/git-filter-tree/src

plumbing/git-filter-tree/src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ pub trait FilterTree {
1616
tree: &'a git2::Tree<'a>,
1717
patterns: &[&str], // TODO create a `git-glob` crate to handle patterns more gracefully
1818
) -> Result<git2::Tree<'a>, Error>;
19+
20+
/// Filters tree entries by gitattributes and returns a new tree with contents filtered.
21+
/// Recursively walks the tree and matches attributes against full paths from the tree root.
22+
///
23+
/// The `attributes` type is an array of string slices. For attributes which haves values,
24+
/// not simply set or unset, use typical `.gitattributes` syntax.
25+
fn filter_by_attributes<'a>(
26+
&'a self,
27+
tree: &'a git2::Tree<'a>,
28+
attributes: &[&str],
29+
) -> Result<git2::Tree<'a>, Error>;
1930
}
2031

2132
impl FilterTree for git2::Repository {
@@ -53,6 +64,14 @@ impl FilterTree for git2::Repository {
5364
// Recursively filter the tree
5465
filter_tree_recursive(self, tree, None, &matcher)
5566
}
67+
68+
fn filter_by_attributes<'a>(
69+
&'a self,
70+
_tree: &'a git2::Tree<'a>,
71+
_attributes: &[&str],
72+
) -> Result<git2::Tree<'a>, Error> {
73+
todo!()
74+
}
5675
}
5776

5877
/// Recursively filters a tree, matching patterns against full paths.

0 commit comments

Comments
 (0)