Files

28 lines
891 B
Rust

//! Copyright (c) 2022-2026 GitDataAi All rights reserved.
use crate::bare::GitBare;
use crate::error::GitResult;
use crate::pb::ReferenceAdvertisement;
impl GitBare {
pub fn list_refs(&self) -> GitResult<Vec<ReferenceAdvertisement>> {
let repo = self.gix_repo()?;
let mut refs = Vec::new();
for r in repo.references()?.all()? {
let mut r = match r {
Ok(r) => r,
Err(_) => continue,
};
let hex = r.peel_to_id().map(|id| id.to_string()).unwrap_or_default();
refs.push(ReferenceAdvertisement {
name: r.name().to_string(),
target_oid: Some(self.oid_to_pb(hex)),
peeled_oid: None,
symbolic: r.target().try_id().is_none(),
symbolic_target: String::new(),
});
}
Ok(refs)
}
}