Skip to content

Commit 59148a2

Browse files
committed
feat: add topo::Builder::new fn for creating a bare builder
Previously, the only way to create a `Builder` would be via `Builder::from_iters`. That fn takes as arguments both the tips and ends, and used to be the only possibility for specifying either of them during the building process. However, in order to enhance the builder- likeness of `Builder`, we recently introduced fns `with_tips` and `with_ends` for adding additional tips and ends. With those fns, the only component which needs to be supplied up-front is `find`. Users can specify and empty `Iterator` and `None` for `tips` and `ends` respectively when calling `Builder::from_iters` and add additional tips and ends at their leisure, without the need to chain `Iterator`s or collecting them in some external data structure. Now, calling `Builder::from_iters` with a empty lists for tips and ends is a bit awkward. Thus, we provide a new method for creating a bare `Builder`.
1 parent a7a8d7c commit 59148a2

File tree

1 file changed

+14
-0
lines changed
  • gix-traverse/src/commit/topo

1 file changed

+14
-0
lines changed

gix-traverse/src/commit/topo/init.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ where
4444
}
4545
}
4646

47+
/// Create a new `Builder` for a [`Topo`] that reads commits from a
48+
/// repository with `find`.
49+
pub fn new(find: Find) -> Self {
50+
Self {
51+
commit_graph: Default::default(),
52+
find,
53+
sorting: Default::default(),
54+
parents: Default::default(),
55+
tips: Default::default(),
56+
ends: Default::default(),
57+
predicate: |_| true,
58+
}
59+
}
60+
4761
/// Add commits to start reading from. The behavior is similar to specifying
4862
/// additional `ends` in `git rev-list --topo-order ^ends tips`.
4963
pub fn with_tips(mut self, tips: impl IntoIterator<Item = impl Into<ObjectId>>) -> Self {

0 commit comments

Comments
 (0)