Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/cargo_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::tracking;
use crate::utils::{resolved_command, truncate};
use anyhow::{Context, Result};
use std::cmp::Ordering;
use std::collections::HashMap;
use std::ffi::OsString;
use std::sync::OnceLock;
Expand Down Expand Up @@ -480,12 +481,10 @@ fn filter_cargo_nextest(output: &str) -> String {
.and_then(|m| m.as_str().parse().ok())
.unwrap_or(0);

let binary_text = if binaries == 1 {
"1 binary".to_string()
} else if binaries > 1 {
format!("{} binaries", binaries)
} else {
String::new()
let binary_text = match binaries.cmp(&1) {
Ordering::Greater => format!("{} binaries", binaries),
Ordering::Equal => "1 binary".to_string(),
Ordering::Less => String::new(),
};

if failed == 0 {
Expand Down
6 changes: 5 additions & 1 deletion src/env_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::tracking;
use anyhow::Result;
use std::collections::HashSet;
use std::env;
use std::fmt::Write;

/// Show filtered environment variables (hide sensitive data)
pub fn run(filter: Option<&str>, show_all: bool, verbose: u8) -> Result<()> {
Expand Down Expand Up @@ -121,7 +122,10 @@ pub fn run(filter: Option<&str>, show_all: bool, verbose: u8) -> Result<()> {
println!("\nTotal: {} vars (showing {} relevant)", total, shown);
}

let raw: String = vars.iter().map(|(k, v)| format!("{}={}\n", k, v)).collect();
let raw: String = vars.iter().fold(String::new(), |mut output, (k, v)| {
let _ = writeln!(output, "{}={}", k, v);
output
});
let rtk = format!("{} vars -> {} shown", total, shown);
timer.track("env", "rtk env", &raw, &rtk);
Ok(())
Expand Down
8 changes: 3 additions & 5 deletions src/gh_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,12 +655,10 @@ fn list_issues(args: &[String], _verbose: u8, ultra_compact: bool) -> Result<()>
} else {
"C"
}
} else if state == "OPEN" {
"[open]"
} else {
if state == "OPEN" {
"[open]"
} else {
"[closed]"
}
"[closed]"
};
let line = format!(" {} #{} {}\n", icon, number, truncate(title, 60));
filtered.push_str(&line);
Expand Down
32 changes: 15 additions & 17 deletions src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,25 +915,23 @@ fn run_commit(args: &[String], verbose: u8, global_args: &[String]) -> Result<()
println!("{}", compact);

timer.track(&original_cmd, "rtk git commit", &raw_output, &compact);
} else if stderr.contains("nothing to commit") || stdout.contains("nothing to commit") {
println!("ok (nothing to commit)");
timer.track(
&original_cmd,
"rtk git commit",
&raw_output,
"ok (nothing to commit)",
);
} else {
if stderr.contains("nothing to commit") || stdout.contains("nothing to commit") {
println!("ok (nothing to commit)");
timer.track(
&original_cmd,
"rtk git commit",
&raw_output,
"ok (nothing to commit)",
);
} else {
if !stderr.trim().is_empty() {
eprint!("{}", stderr);
}
if !stdout.trim().is_empty() {
eprint!("{}", stdout);
}
timer.track(&original_cmd, "rtk git commit", &raw_output, &raw_output);
std::process::exit(output.status.code().unwrap_or(1));
if !stderr.trim().is_empty() {
eprint!("{}", stderr);
}
if !stdout.trim().is_empty() {
eprint!("{}", stdout);
}
timer.track(&original_cmd, "rtk git commit", &raw_output, &raw_output);
std::process::exit(output.status.code().unwrap_or(1));
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/rake_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use anyhow::{Context, Result};
/// `rails test` which handles single files, multiple files, and line-number
/// syntax (`file.rb:15`) natively.
fn select_runner(args: &[String]) -> (&'static str, Vec<String>) {
let has_test_subcommand = args.first().map_or(false, |a| a == "test");
let has_test_subcommand = args.first().is_some_and(|a| a == "test");
if !has_test_subcommand {
return ("rake", args.to_vec());
}
Expand Down