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
use std::sync::{mpsc, Arc};
use std::thread;
use config::Config;
use errors::Result;
use repo::Repo;
use report::Report;
pub fn execute(mut config: Config) -> Result<Report> {
let repos = config.get_repos();
let n_repos = repos.len();
let mut report = Report::new(&repos);
report.pad_repo_output();
let (tx, rx) = mpsc::channel();
for repo in repos {
let tx = tx.clone();
let repo = Arc::new(repo);
thread::spawn(move || {
let path = repo.path();
let stash = repo.get_stash_list();
tx.send((path, stash)).unwrap();
});
}
for _ in 0..n_repos {
let (path, stash) = rx.recv().unwrap();
let repo = Repo::new(path.to_string());
for line in stash {
report.add_repo_message(&repo, line);
}
}
Ok(report)
}