blob: 25652ed0bd342d8d9c7a19872de989ee378d9f17 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
//! 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();
}
}
});
}
}
|