wayver's git archive


a simple self-hosted git server
git clone https://git.wayver.dev/bile

src/git/branch.rs@main

raw
Date Commit Message Author Files + -
2026-02-24 00:53 cleanup wayverd 5 25 430
...

1use git2::{Branch, BranchType, Reference};
2
3use crate::{error::Result, git::Repository};
4
5impl Repository {
6    #[tracing::instrument(skip_all)]
7    pub(crate) fn branches(&self) -> Result<Vec<Reference<'_>>> {
8        let references = self.inner.references()?;
9
10        let branches = references
11            .filter_map(Result::ok)
12            .filter(Reference::is_branch)
13            .collect();
14
15        Ok(branches)
16    }
17
18    #[tracing::instrument(skip_all)]
19    pub(crate) fn branches_of_type(&self, typ: BranchType) -> Result<Vec<Branch<'_>>> {
20        let branches = self
21            .inner
22            .branches(Some(typ))?
23            .filter_map(|x| if let Ok(x) = x { Some(x.0) } else { None })
24            .collect();
25
26        Ok(branches)
27    }
28}
29