27 lines
681 B
Rust
27 lines
681 B
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::{bare::GitBare, errors::GitResult};
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct BranchSummary {
|
|
pub local_count: usize,
|
|
pub remote_count: usize,
|
|
pub all_count: usize,
|
|
}
|
|
|
|
impl GitBare {
|
|
pub fn branch_summary(&self) -> GitResult<BranchSummary> {
|
|
let repo = self.gix_repo()?;
|
|
let platform = repo.references()?;
|
|
|
|
let local_count = platform.local_branches()?.count();
|
|
let remote_count = platform.remote_branches()?.count();
|
|
|
|
Ok(BranchSummary {
|
|
local_count,
|
|
remote_count,
|
|
all_count: local_count + remote_count,
|
|
})
|
|
}
|
|
}
|