Radish alpha
r
rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt
Git libraries for Radicle
Radicle
Git
Merge remote-tracking branch 'origin/surf/revision-stats'
Fintan Halpenny committed 3 years ago
commit 824e0d5d9bbe53a1c7058fe0ac52b68b5ae092f8
parent c2cc44b
2 files changed +13 -3
modified radicle-surf/src/git/repo.rs
@@ -336,10 +336,20 @@ impl Repository {
        rev.to_commit(self)
    }

-
    /// Gets the [`Stats`] of this repository.
+
    /// Gets the [`Stats`] of this repository starting from the
+
    /// `HEAD` (see [`Repository::head`]) of the repository.
    pub fn stats(&self) -> Result<Stats, Error> {
+
        self.stats_from(&self.head()?)
+
    }
+

+
    /// Gets the [`Stats`] of this repository starting from the given
+
    /// `rev`.
+
    pub fn stats_from<R>(&self, rev: &R) -> Result<Stats, Error>
+
    where
+
        R: Revision,
+
    {
        let branches = self.branches(Glob::all_heads())?.count();
-
        let mut history = self.history(self.head()?)?;
+
        let mut history = self.history(rev)?;
        let (commits, contributors) = history.try_fold(
            (0, BTreeSet::new()),
            |(commits, mut contributors), commit| {
modified radicle-surf/src/source/commit.rs
@@ -174,7 +174,7 @@ pub fn commits<R>(repo: &Repository, revision: &R) -> Result<Commits, Error>
where
    R: git::Revision,
{
-
    let stats = repo.stats()?;
+
    let stats = repo.stats_from(revision)?;
    let commits = repo.history(revision)?.collect::<Result<Vec<_>, _>>()?;
    let headers = commits.into_iter().map(Header::from).collect();
    Ok(Commits { headers, stats })