summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-01-10 00:28:43 +0800
committer魏曹先生 <1992414357@qq.com>2026-01-10 00:28:43 +0800
commitc3610bfb57d318c9b21096907193a8dcb8b5be57 (patch)
tree7a50a692771c297d29d8738f20cfae342cda2ca1 /src
parent2f018e89c8584bc2bbca91054d0d5e96ed57e42d (diff)
Refactor analyzer result structs for clarity
Diffstat (limited to 'src')
-rw-r--r--src/bin/jv.rs22
-rw-r--r--src/output/analyzer_result.rs18
2 files changed, 30 insertions, 10 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,
diff --git a/src/output/analyzer_result.rs b/src/output/analyzer_result.rs
index a4df762..bb6af56 100644
--- a/src/output/analyzer_result.rs
+++ b/src/output/analyzer_result.rs
@@ -8,8 +8,8 @@ pub struct AnalyzerJsonResult {
pub created: Vec<PathBuf>,
pub lost: Vec<PathBuf>,
pub erased: Vec<PathBuf>,
- pub moved: Vec<(PathBuf, PathBuf)>,
- pub modified: Vec<(PathBuf, ModifiedType)>,
+ pub moved: Vec<MovedItem>,
+ pub modified: Vec<ModifiedItem>,
}
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
@@ -19,3 +19,17 @@ pub enum ModifiedType {
ModifiedButBaseVersionMismatch,
ModifiedButNotHeld,
}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "PascalCase")]
+pub struct MovedItem {
+ pub from: PathBuf,
+ pub to: PathBuf,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "PascalCase")]
+pub struct ModifiedItem {
+ pub path: PathBuf,
+ pub modification_type: ModifiedType,
+}