From 5488aa455c5ee16ce29469a3793bd29f89fa8945 Mon Sep 17 00:00:00 2001 From: Andrei Gherzan Date: Mon, 6 Jul 2026 19:30:28 +0100 Subject: [PATCH 1/2] feat: display list of commits being tested Show abbreviated SHA and first line of each commit message before running checks. Makes it clear which commits are being validated. Example output: Testing 3 commits: 134af565 feat: support short SHAs and symbolic git references 6ab42b7a feat: add --skip-merge-commits flag 2991d580 chore: migrate repository references Signed-off-by: Andrei Gherzan --- src/lib.rs | 2 +- src/main.rs | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9740cb3..674c362 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,7 +17,7 @@ pub use git::{get_commits_in_range, open_repo, resolve_ref}; const SHA_ABBREV_LEN: usize = 8; /// Abbreviates a SHA to the first 8 characters (or less if shorter). -fn abbreviate_sha(sha: &str) -> &str { +pub fn abbreviate_sha(sha: &str) -> &str { &sha[..SHA_ABBREV_LEN.min(sha.len())] } diff --git a/src/main.rs b/src/main.rs index b7fcc60..197918a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 use clap::{Parser, Subcommand}; -use gitlance::{checks, git, output, run_check}; +use gitlance::{abbreviate_sha, checks, git, output, run_check}; use std::process::exit; #[derive(Parser)] @@ -45,6 +45,20 @@ enum Commands { All, } +/// Displays the list of commits being tested +fn display_commits(commits: &[git::Commit]) { + let count = commits.len(); + let plural = if count == 1 { "commit" } else { "commits" }; + println!("Testing {} {}:", count, plural); + + for commit in commits { + let sha_abbrev = abbreviate_sha(&commit.sha); + let first_line = commit.message.lines().next().unwrap_or(""); + println!(" {} {}", sha_abbrev, first_line); + } + println!(); +} + fn main() { let cli = Cli::parse(); @@ -102,6 +116,9 @@ fn main() { exit(0); } + // Display the commits being tested + display_commits(&commits); + // Run the appropriate check(s) let overall_passed = match command { Commands::WipFixup => run_check("WIP/Fixup", &checks::wip_fixup::check_commits(&commits)), From 99c9726e3c08ce8ed25b6c6dcd642dd6f23099ca Mon Sep 17 00:00:00 2001 From: Andrei Gherzan Date: Wed, 22 Jul 2026 14:14:50 +0100 Subject: [PATCH 2/2] refactor: use idiomatic slice access in abbreviate_sha Replace manual bounds checking with str::get() which returns None for out-of-bounds access, making the code more idiomatic. Signed-off-by: Andrei Gherzan --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 674c362..449d0f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,7 +18,7 @@ const SHA_ABBREV_LEN: usize = 8; /// Abbreviates a SHA to the first 8 characters (or less if shorter). pub fn abbreviate_sha(sha: &str) -> &str { - &sha[..SHA_ABBREV_LEN.min(sha.len())] + sha.get(..SHA_ABBREV_LEN).unwrap_or(sha) } /// Runs a check and reports results.