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.
43 lines
1.2 KiB
43 lines
1.2 KiB
//! 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();
|
|
}
|
|
Octopus(c, branches) => {
|
|
println!("{}: {}", c.id_str(), c.summary());
|
|
for _b in branches {
|
|
tx.send(_b.get_all()).unwrap();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|