Skip to main content

git_global/subcommands/
ahead.rs

1//! The `ahead` subcommand: shows repositories that have commits not pushed to a remote
2
3use crate::config::Config;
4use crate::errors::Result;
5use crate::parallel::{default_parallelism, run_parallel};
6use crate::repo::Repo;
7use crate::report::Report;
8
9/// Runs the `ahead` subcommand.
10pub fn execute(mut config: Config) -> Result<Report> {
11    let repos = config.get_repos();
12    let mut report = Report::new(&repos);
13
14    let results =
15        run_parallel(repos, default_parallelism(), |repo| repo.is_ahead());
16
17    for (path, ahead) in results {
18        if ahead {
19            let repo = Repo::new(path);
20            report.add_repo_message(&repo, String::new());
21        }
22    }
23
24    Ok(report)
25}