History

remaining docs for git-commitgraph crate

Sebastian Thiel committed 5 years ago

Commit 91461761 parent a81ea673 files · +22 −1Browse files

Showing the changes to git-commitgraph/src/graph (2 of 3 files). Show all

Unified · Split

2 files
  1. git-commitgraph/src/graph/mod.rs +2 −0
  2. git-commitgraph/src/graph/verify.rs +9 −0
git-commitgraph/src/graph/mod.rs+2−0
@@ -1,6 +1,7 @@
11 //! Operations on a complete commit graph.
22 mod access;
33 mod init;
4+///
45 pub mod verify;
56
67 use crate::file::File;
@@ -15,6 +16,7 @@ pub struct Graph { · 8 unmodified lines
1516 files: Vec<File>,
1617 }
1718
19+/// A generalized position for use in [`Graph`].
1820 #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, Hash)]
1921 pub struct Position(pub u32);
2022
git-commitgraph/src/graph/verify.rs+9−0
@@ -50,15 +50,24 @@ pub enum Error<E: std::error::Error + 'static> { · 49 unmodified lines
5050 TooManyFiles(usize),
5151 }
5252
53+/// Statistics gathered while verifying the integrity of the graph as returned by [`Graph::verify_integrity()]`.
5354 #[derive(Clone, Debug, Eq, PartialEq)]
5455 #[cfg_attr(feature = "serde1", derive(serde::Deserialize, serde::Serialize))]
5556 pub struct Outcome {
57+ /// The longest consecutive amount of commits in a chain of commits.
58+ ///
59+ /// For example, a repository with 10 commits would have 10 as value.
5660 pub longest_path_length: Option<u32>,
61+ /// The total amount traversed commits.
5762 pub num_commits: u32,
63+ /// A mapping of `parent-count -> amount of [commits][file::Commit] with that count`.
5864 pub parent_counts: BTreeMap<u32, u32>,
5965 }
6066
6167 impl Graph {
68+ /// Traverse all commits in the graph and call `processor(&commit) -> Result<(), E>` on it while verifying checksums.
69+ ///
70+ /// When `processor` returns an error, the entire verification is stopped and the error returned.
6271 pub fn verify_integrity<E>(
6372 &self,
6473 mut processor: impl FnMut(&file::Commit<'_>) -> Result<(), E>,