|
|
|
//! A test binary to use during development
|
|
|
|
|
|
|
|
use std::sync::mpsc::channel;
|
|
|
|
use supergit::{BranchCommit, Repository};
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let path = match std::env::args().nth(1) {
|
|
|
|
Some(p) => p,
|
|
|
|
None => {
|
|
|
|
eprintln!("USAGE: supergit-test <path>");
|
|
|
|
std::process::exit(2);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
let repo = Repository::open(path.as_str()).unwrap();
|
|
|
|
|
|
|
|
let (tx, rx) = channel();
|
|
|
|
let branches = repo.branches().unwrap();
|
|
|
|
|
|
|
|
branches
|
|
|
|
.into_iter()
|
|
|
|
.filter(|b| b.name == Some("main".to_string()))
|
|
|
|
.for_each(|b| tx.send(b.get_all()).unwrap());
|
|
|
|
|
|
|
|
// Iterate over all branch iterators we get
|
|
|
|
while let Some(biter) = rx.recv().ok() {
|
|
|
|
use BranchCommit::*;
|
|
|
|
|
|
|
|
biter.for_each(|bc| match bc {
|
|
|
|
Commit(c) => println!("{}: {}", c.id_str(), c.summary()),
|
|
|
|
Merge(c, _b) => {
|
|
|
|
println!("{}: {}", c.id_str(), c.summary());
|
|
|
|
// tx.send(b.get_all()).unwrap();
|
|
|
|
}
|
|
|
|
_ => todo!(),
|
|
|
|
});
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// let rr = RawRepository::open(path.as_str()).unwrap();
|
|
|
|
// let branches = rr.parse_branches().unwrap();
|
|
|
|
|
|
|
|
// for branch in branches {
|
|
|
|
// if branch.name.as_str() != "main" && continue {}
|
|
|
|
// println!("Branch: {}", branch.name);
|
|
|
|
|
|
|
|
// branch.enumerate(" ".into(), &rr.inner);
|
|
|
|
// }
|
|
|
|
}
|