From 77822470f0546bc2bc07c84dec19ac4625562dbe Mon Sep 17 00:00:00 2001 From: Sheldon Date: Thu, 19 Mar 2026 15:43:04 +0800 Subject: [PATCH 1/2] feat: Add Homebrew FETCH_HEAD age check & format diff src/commands/update.rs: Add check for Homebrew repo FETCH_HEAD age; run brew update if older than 1 day (18) src/core/diff.rs: Adjust code formatting (split .into_iter(), combine else block lines) (7) --- .zed/debug.json | 14 ++++++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- src/commands/update.rs | 18 ++++++++++++++++++ src/core/diff.rs | 10 +++++----- 5 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 .zed/debug.json diff --git a/.zed/debug.json b/.zed/debug.json new file mode 100644 index 0000000..5f73be3 --- /dev/null +++ b/.zed/debug.json @@ -0,0 +1,14 @@ +[ + { + "label": "Build & Debug", + "adapter": "CodeLLDB", + "build": { + "command": "cargo", + "args": ["run", "--", "--dry", "-v"] + }, + "program": "$ZED_WORKTREE_ROOT/target/debug/gim", + "sourceLanguages": ["rust"], + "request": "launch", + "args": [] + } +] diff --git a/Cargo.lock b/Cargo.lock index 580b833..dda638c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -441,7 +441,7 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "git-intelligence-message" -version = "2.1.1" +version = "2.1.2" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index 3536c2c..818a909 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "git-intelligence-message" -version = "2.1.1" +version = "2.1.2" edition = "2024" description = "An advanced Git commit message generation utility with AI assistance" authors = ["Sheldon.Wei"] diff --git a/src/commands/update.rs b/src/commands/update.rs index 2f2b40e..0ca9a80 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs @@ -79,6 +79,24 @@ fn new_version_available() -> Result<(bool, Version, Version), Box Result> { + if let Ok(repo) = String::from_utf8(Command::new("brew").arg("--repository").output()?.stdout) { + let fetch_head = format!("{}/.git/FETCH_HEAD", repo.trim()); + let should_update = match std::fs::metadata(&fetch_head) { + Ok(meta) => { + let modified = meta.modified()?; + std::time::SystemTime::now().duration_since(modified)? + > std::time::Duration::from_secs(86400) + } + Err(_) => true, + }; + + if should_update { + output::print_verbose("Homebrew index is outdated, running 'brew update'..."); + let _ = Command::new("brew").arg("update").status(); + } else { + output::print_verbose("Homebrew index was updated recently."); + } + } // Get latest version from Homebrew let output = Command::new("brew") .args(["info", "--json=v2", REPOSITORY]) diff --git a/src/core/diff.rs b/src/core/diff.rs index 3a46050..78c9f28 100644 --- a/src/core/diff.rs +++ b/src/core/diff.rs @@ -99,7 +99,8 @@ fn select_files(changes: Vec, max_files: usize) -> Vec { "Code changes ({} lines) exceed 50% of total ({} lines), filtering to code files only", code_lines, total_lines )); - changes.into_iter() + changes + .into_iter() .filter(|c| c.file_type == FileType::Code) .collect() } else { @@ -115,14 +116,13 @@ fn select_files(changes: Vec, max_files: usize) -> Vec { // Take top N files by lines changed if max_files is set if max_files > 0 { - filtered_changes.into_iter() + filtered_changes + .into_iter() .take(max_files) .map(|c| c.path) .collect() } else { - filtered_changes.into_iter() - .map(|c| c.path) - .collect() + filtered_changes.into_iter().map(|c| c.path).collect() } } From 2a9c46fb117ba64a8004575443718b2b443e2dad Mon Sep 17 00:00:00 2001 From: Sheldon Date: Wed, 8 Apr 2026 23:04:38 +0800 Subject: [PATCH 2/2] feat: Implement and call print_promotion src/main.rs: Add call to print_promotion() (1) src/utils/output.rs: Add print_promotion() function (6) --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 1 + src/utils/output.rs | 7 +++++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dda638c..faa0a6a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -441,7 +441,7 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "git-intelligence-message" -version = "2.1.2" +version = "2.1.3" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index 818a909..4340b72 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "git-intelligence-message" -version = "2.1.2" +version = "2.1.3" edition = "2024" description = "An advanced Git commit message generation utility with AI assistance" authors = ["Sheldon.Wei"] diff --git a/src/main.rs b/src/main.rs index 2130674..c424d20 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,6 +35,7 @@ async fn main() { std::process::exit(1); } utils::output::print_normal(""); + utils::output::print_promotion(); // Give the background update check task a chance to complete if let Some(handle) = update_check_handle { diff --git a/src/utils/output.rs b/src/utils/output.rs index d6c4fdb..4992a3f 100644 --- a/src/utils/output.rs +++ b/src/utils/output.rs @@ -70,3 +70,10 @@ pub fn print_warning(message: &str) { eprintln!("⚠️ {}", message); } } + +/// Prints promotion message for Rudist Redis client. +pub fn print_promotion() { + if !is_quiet() { + println!("\n🚀 Give AI-powered Redis GUI a try! https://redis-egui-client.pages.dev/"); + } +}