diff --git a/src/main.rs b/src/main.rs index 954f571..764ed13 100644 --- a/src/main.rs +++ b/src/main.rs @@ -157,8 +157,8 @@ fn main() { match git::get_commits_in_range(&repo, &base, &head, cli.skip_merge_commits) { Ok(commits) if commits.is_empty() => { - output::notice("No commits found in the specified range"); - exit(0); + output::error(&format!("No commits found in the range {}..{}", base, head)); + exit(1); } Ok(commits) => commits, Err(e) => { diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 13797e3..d303366 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -279,16 +279,30 @@ mod tests { let base_sha = create_commit(&repo_path, "initial"); - // Using the same SHA for base and head should result in no commits + // Using the same SHA for base and head should result in no commits and fail + let output = run( + None, + Some(&repo_path), + Some(&base_sha), + Some(&base_sha), + None, + false, + ); assert!( - run_check( - None, - Some(&repo_path), - Some(&base_sha), - Some(&base_sha), - None - ), - "Expected success with empty commit range" + !output.status.success(), + "Expected failure with empty commit range" + ); + + // Emit an error annotation (not a notice) naming the range, so the + // misconfiguration is visible and diagnosable in CI. + let stdout = String::from_utf8_lossy(&output.stdout); + assert!( + stdout.contains(&format!( + "::error::No commits found in the range {}..{}", + base_sha, base_sha + )), + "Expected an error annotation naming the range, got: {}", + stdout ); }