My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/apps/servers/octopus/supergit/src/raw/branch.rs

51 lines
1.3 KiB

use super::{HashId, RawRepository};
use crate::Branch;
use git2::{Commit, Repository};
/// Represent some raw branch metadata
pub struct RawBranch {
pub name: String,
pub head: HashId,
}
fn print_commit(i: &String, c: &Commit) {
println!(
"{}{}: {}",
i,
c.id().to_string(),
c.message().unwrap().trim().split("\n").nth(0).unwrap()
);
}
fn print_parent_tree(c: &Commit, indent: String) {
c.parents().for_each(|c| {
println!(
"{}{}: {}",
indent,
c.id().to_string(),
c.message().unwrap().trim().split("\n").nth(0).unwrap()
);
print_parent_tree(&c, indent.clone());
});
}
impl RawBranch {
/// Consume branch reference and enumerate real branch history
pub fn into_branch(self, repo: &mut RawRepository) -> Branch {
todo!()
}
/// **REMOVE ME** A test function to do some test things
pub fn enumerate(&self, indent: String, repo: &Repository) {
let c = repo.find_commit((&self.head).into()).unwrap();
println!(
"{}{}: {}",
indent,
c.id().to_string(),
c.message().unwrap().trim().split("\n").nth(0).unwrap()
);
print_parent_tree(&c, indent);
}
}