Skip to content

Commit 0682c96

Browse files
committed
Added a message if no matching committers found
1 parent 8612c98 commit 0682c96

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

stackmuncher/src/cmd_munch.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::help;
33
use crate::signing::ReportSignature;
44
use crate::submission::submit_report;
55
use futures::stream::{FuturesUnordered, StreamExt};
6+
use stackmuncher_lib::contributor::Contributor;
67
use stackmuncher_lib::report_brief::TechOverview;
78
use stackmuncher_lib::{code_rules::CodeRules, config::Config, git, report::Report, utils::hash_str_sha1};
89
use std::path::Path;
@@ -128,7 +129,10 @@ pub(crate) async fn run(config: AppConfig) -> Result<(), ()> {
128129

129130
// combine multiple contributor reports from different identities
130131
debug!("Combining {} contributor reports", contributor_reports.len());
131-
if !contributor_reports.is_empty() {
132+
if contributor_reports.is_empty() {
133+
// there were no matching contributors
134+
print_no_contributions_msg(&config.lib_config.git_identities, contributors);
135+
} else {
132136
// seed the combined report from the 1st contributor report in the list of all contributor reports
133137
let (mut combined_report, contributor_git_id) = contributor_reports.pop().unwrap();
134138
combined_report.reset_combined_contributor_report(contributor_git_id, &list_of_commits, &project_report);
@@ -233,3 +237,38 @@ fn print_combined_stats(report: &Report) {
233237
let per_tech_stats = per_tech_stats.as_slice().join(", ");
234238
println!(" Summary (LoC/libs): {}", per_tech_stats);
235239
}
240+
241+
/// Prints a list of contributors and git identities to help find user git identities
242+
fn print_no_contributions_msg(git_identities: &Vec<String>, contributors: &Vec<Contributor>) {
243+
// is this repo empty?
244+
if contributors.is_empty() {
245+
println!(" This repository has no commits with identifiable committers.");
246+
return;
247+
}
248+
249+
match git_identities.len() {
250+
0 => {
251+
println!();
252+
println!(" No commits were selected for analysis.");
253+
println!(" Configure `user.email` Git setting or use `--email` CLI params to add committer emails.");
254+
println!();
255+
}
256+
1 => {
257+
println!();
258+
println!(
259+
"Found no commits from {}. Did you make commits with a different email?",
260+
git_identities[0]
261+
);
262+
println!(" Run `git shortlog -s -e --all` to see all committer emails in this repo.");
263+
println!(" Add more of your committer emails with `stackmuncher config --emails \"[email protected],[email protected]\"");
264+
println!();
265+
}
266+
_ => {
267+
println!();
268+
println!(" Found no commits from any of: {}.", git_identities.join(", "));
269+
println!(" Run `git shortlog -s -e --all` to see all committer emails in this repo.");
270+
println!(" Add more of your committer emails with `stackmuncher config --emails \"[email protected],[email protected]\"");
271+
println!();
272+
}
273+
}
274+
}

0 commit comments

Comments
 (0)