Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Refactor Option checks to use is_some_and
Maximilian Roos424bd7f17d91
diff --git a/src/commands/list/json_output.rs b/src/commands/list/json_output.rsindex 1ef902461..0e5f0604a 100644--- a/src/commands/list/json_output.rs+++ b/src/commands/list/json_output.rs@@ -225,9 +225,9 @@ impl JsonItem {ItemKind::Branch => ("branch", None),};- let is_main = worktree_data.map(|d| d.is_main).unwrap_or(false);- let is_current = worktree_data.map(|d| d.is_current).unwrap_or(false);- let is_previous = worktree_data.map(|d| d.is_previous).unwrap_or(false);+ let is_main = worktree_data.is_some_and(|d| d.is_main);+ let is_current = worktree_data.is_some_and(|d| d.is_current);+ let is_previous = worktree_data.is_some_and(|d| d.is_previous);// Commit infolet sha = item.head.clone();diff --git a/src/commands/list/mod.rs b/src/commands/list/mod.rsindex 0b7b256e0..27866315c 100644--- a/src/commands/list/mod.rs+++ b/src/commands/list/mod.rs@@ -228,20 +228,14 @@ impl SummaryMetrics {if data.working_tree_diff.as_ref()- .map(|d| !d.is_empty())- .unwrap_or(false)+ .is_some_and(|d| !d.is_empty()){self.dirty_worktrees += 1;}} else {// Distinguish local vs remote branches by presence of '/' in name// Remote branches are like "origin/feature", local are like "feature"- if item- .branch- .as_ref()- .map(|b| b.contains('/'))- .unwrap_or(false)- {+ if item.branch.as_ref().is_some_and(|b| b.contains('/')) {self.remote_branches += 1;} else {self.local_branches += 1;diff --git a/src/commands/list/model.rs b/src/commands/list/model.rsindex 25fdff946..556a099be 100644--- a/src/commands/list/model.rs+++ b/src/commands/list/model.rs@@ -514,28 +514,19 @@ impl ListItem {// Simplified status computation for branches// Only compute symbols that apply to branches (no working tree, git operation, or worktree attrs)- // Determine integration state for branches- let (same_commit, integration_reason) = if self.is_ancestor == Some(true) {- if self.counts.as_ref().is_some_and(|c| c.behind == 0) {- (true, None) // Same commit as main- } else {- (false, Some(IntegrationReason::Ancestor)) // Main has moved past- }- } else if self.has_file_changes == Some(false) {- (false, Some(IntegrationReason::NoAddedChanges))- } else if self.committed_trees_match == Some(true) {- (false, Some(IntegrationReason::TreesMatch))- } else if self.would_merge_add == Some(false) {- (false, Some(IntegrationReason::MergeAddsNothing))- } else if let Some(ref c) = self.counts {- if c.ahead == 0 && c.behind == 0 {- (true, None) // Same commit as main (fallback)- } else {- (false, None)- }- } else {- (false, None)- };+ // Branches don't have working trees, so pass empty diff as "inherently clean"+ let empty_diff = LineDiff::default();+ let (same_commit, integration_reason) = determine_integration_state(+ false, // branches are never main worktree+ default_branch,+ self.is_ancestor,+ self.counts.as_ref().map(|c| c.behind),+ self.committed_trees_match.unwrap_or(false),+ self.has_file_changes,+ self.would_merge_add,+ Some(&empty_diff), // branches are always "clean" (no working tree)+ &None, // no working_tree_diff_with_main for branches+ );// Compute main statelet main_state = MainState::from_integration_and_counts(