diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-01-10 00:28:43 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-01-10 00:28:43 +0800 |
| commit | c3610bfb57d318c9b21096907193a8dcb8b5be57 (patch) | |
| tree | 7a50a692771c297d29d8738f20cfae342cda2ca1 /src/bin | |
| parent | 2f018e89c8584bc2bbca91054d0d5e96ed57e42d (diff) | |
Refactor analyzer result structs for clarity
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/jv.rs | 22 |
1 files changed, 14 insertions, 8 deletions
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<PathBuf> = analyzed.created.iter().cloned().collect(); let mut lost: Vec<PathBuf> = analyzed.lost.iter().cloned().collect(); let mut erased: Vec<PathBuf> = analyzed.erased.iter().cloned().collect(); - let mut moved: Vec<(PathBuf, PathBuf)> = analyzed + let mut moved: Vec<MovedItem> = 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<ModifiedItem> = 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, |
