From f8c671b7bceddd8bd38d7764fc1144606ca07ee1 Mon Sep 17 00:00:00 2001 From: Amolith Date: Fri, 6 Mar 2026 18:11:20 -0700 Subject: [PATCH] Fix redundant [closed] markers in td show when all blockers are closed When all blockers are resolved, 'td show' was printing both '[all closed]' as a prefix AND '[closed]' after each blocker ID. The prefix makes the individual markers redundant. Now: - All closed: '[all closed] id1, id2' (no per-ID markers) - All open: 'id1, id2' (no brackets) - Mixed: 'open1, open2, closed1 [closed], closed2 [closed]' --- Cargo.lock | 2 +- src/cmd/show.rs | 12 ++++++++---- tests/cli_list_show.rs | 17 ++++++++++------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c4dc3ee6e895f8cf93f91dea4d6371b9482b3b0d..e773bb2a5fb41b0cc4f40399c00d273f791dcf0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3512,7 +3512,7 @@ checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" [[package]] name = "yatd" -version = "0.1.1" +version = "0.1.2" dependencies = [ "anyhow", "assert_cmd", diff --git a/src/cmd/show.rs b/src/cmd/show.rs index e59833bca767d7435080b30cda9744cc826c4338..8f6f16a80a65fa4a34cb5f5b4d823fa5f3f3e594 100644 --- a/src/cmd/show.rs +++ b/src/cmd/show.rs @@ -54,12 +54,16 @@ pub fn run(root: &Path, id: &str, json: bool) -> Result<()> { let blockers = db::partition_blockers(&store, &task.blockers)?; let total = blockers.open.len() + blockers.resolved.len(); if total > 0 { - let mut ids: Vec = blockers.open.iter().map(ToString::to_string).collect(); - ids.extend(blockers.resolved.iter().map(|id| format!("{id} [closed]"))); + let label = if total == 1 { "blocker" } else { "blockers" }; if blockers.open.is_empty() { - println!("blockers: [all closed] {}", ids.join(", ")); + // All closed: prefix with [all closed], no individual markers. + let ids: Vec = blockers.resolved.iter().map(ToString::to_string).collect(); + println!("{label}: [all closed] {}", ids.join(", ")); } else { - println!("blockers: {}", ids.join(", ")); + // Mixed or all open: annotate only the closed ones. + let mut ids: Vec = blockers.open.iter().map(ToString::to_string).collect(); + ids.extend(blockers.resolved.iter().map(|id| format!("{id} [closed]"))); + println!("{label}: {}", ids.join(", ")); } } diff --git a/tests/cli_list_show.rs b/tests/cli_list_show.rs index 32dcb12b89142ba1f69ca02e132a1224291e9c38..ae21c324c49c99a959ada2eecc468e58aef1c434 100644 --- a/tests/cli_list_show.rs +++ b/tests/cli_list_show.rs @@ -274,15 +274,18 @@ fn show_all_closed_blockers_prefixed() { .assert() .success(); - // Singular label, [all closed] prefix. - td(&tmp) + // Singular label, [all closed] prefix, no redundant [closed] on IDs. + let out = td(&tmp) .args(["show", &task]) .current_dir(&tmp) - .assert() - .success() - .stdout(predicate::str::contains("blocker")) - .stdout(predicate::str::contains("[all closed]")) - .stdout(predicate::str::contains(&blocker[blocker.len() - 7..])); + .output() + .unwrap(); + let stdout = String::from_utf8_lossy(&out.stdout); + assert!(stdout.contains("blocker")); + assert!(stdout.contains("[all closed]")); + assert!(stdout.contains(&blocker[blocker.len() - 7..])); + // When all are closed, individual IDs should NOT have [closed] appended. + assert!(!stdout.contains("[closed]")); } #[test]