From c3610bfb57d318c9b21096907193a8dcb8b5be57 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 10 Jan 2026 00:28:43 +0800 Subject: Refactor analyzer result structs for clarity --- src/bin/jv.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/bin/jv.rs') diff --git a/src/bin/jv.rs b/src/bin/jv.rs index 21ec126..0f42318 100644 --- a/src/bin/jv.rs +++ b/src/bin/jv.rs @@ -89,7 +89,7 @@ use just_enough_vcs_cli::{ output::{ accounts::{AccountItem, AccountListJsonResult}, align::{AlignJsonResult, AlignTaskMapping}, - analyzer_result::{AnalyzerJsonResult, ModifiedType}, + analyzer_result::{AnalyzerJsonResult, ModifiedItem, ModifiedType, MovedItem}, here::{HereJsonResult, HereJsonResultItem}, info::{InfoHistory, InfoJsonResult}, share::{SeeShareResult, ShareItem, ShareListResult}, @@ -2108,12 +2108,15 @@ async fn jv_status(args: StatusArgs) { let mut created: Vec = analyzed.created.iter().cloned().collect(); let mut lost: Vec = analyzed.lost.iter().cloned().collect(); let mut erased: Vec = analyzed.erased.iter().cloned().collect(); - let mut moved: Vec<(PathBuf, PathBuf)> = analyzed + let mut moved: Vec = analyzed .moved .iter() - .map(|(_, (from, to))| (from.clone(), to.clone())) + .map(|(_, (from, to))| MovedItem { + from: from.clone(), + to: to.clone(), + }) .collect(); - let mut modified: Vec<(PathBuf, ModifiedType)> = analyzed + let mut modified: Vec = analyzed .modified .iter() .cloned() @@ -2144,7 +2147,7 @@ async fn jv_status(args: StatusArgs) { } }; - let modified_type = if !holder_match { + let modification_type = if !holder_match { ModifiedType::ModifiedButNotHeld } else if !base_version_match { ModifiedType::ModifiedButBaseVersionMismatch @@ -2152,7 +2155,10 @@ async fn jv_status(args: StatusArgs) { ModifiedType::Modified }; - (path, modified_type) + ModifiedItem { + path, + modification_type, + } }) .collect(); @@ -2160,8 +2166,8 @@ async fn jv_status(args: StatusArgs) { created.sort(); lost.sort(); erased.sort(); - moved.sort_by(|a, b| a.0.cmp(&b.0).then(a.1.cmp(&b.1))); - modified.sort_by(|a, b| a.0.cmp(&b.0)); + moved.sort_by(|a, b| a.from.cmp(&b.from).then(a.to.cmp(&b.to))); + modified.sort_by(|a, b| a.path.cmp(&b.path)); let json_result = AnalyzerJsonResult { created, -- cgit