summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2025-12-08 19:42:12 +0800
committer魏曹先生 <1992414357@qq.com>2025-12-08 19:42:12 +0800
commit05f91c8a0191b2cb4ef0baa9690abc5d83fd2f1e (patch)
tree239f48d547d409d82493ca9a4362a654ec0afb2f
parent9221e90c81b43b796d8ad8be08b4fa65a55d24de (diff)
Add --overwrite flag to track command and show skipped files
The flag allows users to confirm overwriting locally modified files during sync operations. When files are skipped due to local modifications, a warning message now displays the skipped files and provides the command to overwrite them.
-rw-r--r--locales/help_docs/en.yml12
-rw-r--r--locales/help_docs/zh-CN.yml11
-rw-r--r--src/bin/jv.rs24
3 files changed, 37 insertions, 10 deletions
diff --git a/locales/help_docs/en.yml b/locales/help_docs/en.yml
index 9009f4b..fa458f2 100644
--- a/locales/help_docs/en.yml
+++ b/locales/help_docs/en.yml
@@ -474,11 +474,6 @@ jv:
**DOWN**: %{old_files} to update, %{download_files} to download
**UP** : %{new_files} to track, %{modified_files} to commit
- need_upload: |
- Since your specified tracking operation involves uploading, you need to provide detailed description of your changes
- Ready to commit? Use `jv track <files_to_upload> --work` to start filling in commit information
- Don't want to use command line editor? Use `jv track <files_to_upload> --msg <commit_message>` to commit directly
-
fail:
std:
current_dir: Failed to get current directory
@@ -874,6 +869,13 @@ jv:
Tracked %{count} files to latest!
**Total**: %{created} Created, %{updated} Updated, %{synced} Synced
+ tip_has_skipped: |
+ **Note**: Skipped %{skipped_num} sync tasks
+ %{skipped}
+ Because local modifications exist, the sync task will forcibly overwrite your changes.
+ Please confirm you really want to overwrite these files.
+ Use `jv track . --overwrite` to confirm overwriting them
+
structure_changes_not_solved: |
There are unresolved local lost and moved items!
**Tip**: Use `jv align` to view items that need to be resolved
diff --git a/locales/help_docs/zh-CN.yml b/locales/help_docs/zh-CN.yml
index aaf6706..ddcd00f 100644
--- a/locales/help_docs/zh-CN.yml
+++ b/locales/help_docs/zh-CN.yml
@@ -474,11 +474,6 @@ jv:
**下行**:%{old_files} 个待更新,%{download_files} 个待下载
**上行**:%{new_files} 个待追踪,%{modified_files} 个待提交
- need_upload: |
- 因为您指定的追踪操作涉及上传,所以需要详细说明您的更改
- 准备好提交了么?使用 `jv track <待上传文件> --work` 开始填写提交信息
- 不想使用命令行编辑器?使用 `jv track <待上传文件> --desc <本次修改信息>` 直接提交
-
fail:
std:
current_dir: 无法获得当前目录
@@ -874,6 +869,12 @@ jv:
追踪 %{count} 个文件至最新!
其中,创建 %{created},更新 %{updated},同步 %{synced}
+ tip_has_skipped: |
+ **注意**:忽略 %{skipped_num} 个同步任务
+ %{skipped}
+ 因本地存在修改,同步任务会强制覆盖您的修改,请确认您确实要覆盖这些文件
+ 使用 `jv track . --overwrite` 确认覆盖它们
+
structure_changes_not_solved: |
本地存在丢失项和移动项未解决!
**提示**:使用 `jv align` 查看需要解决的项
diff --git a/src/bin/jv.rs b/src/bin/jv.rs
index 49f39bc..de92a69 100644
--- a/src/bin/jv.rs
+++ b/src/bin/jv.rs
@@ -525,6 +525,10 @@ struct TrackFileArgs {
/// Track file pattern
track_file_pattern: Option<String>,
+ /// Overwrite modified
+ #[arg(short = 'o', long = "overwrite")]
+ allow_overwrite: bool,
+
/// Commit - Description
#[arg(short, long)]
desc: Option<String>,
@@ -2366,6 +2370,7 @@ async fn jv_track(args: TrackFileArgs) {
};
let files = track_files.iter().cloned().collect();
+ let overwrite = args.allow_overwrite;
let update_info = get_update_info(local_workspace, &files, args).await;
match proc_track_file_action(
@@ -2375,6 +2380,7 @@ async fn jv_track(args: TrackFileArgs) {
relative_pathes: files,
file_update_info: update_info,
print_infos: true,
+ allow_overwrite_modified: overwrite,
},
)
.await
@@ -2384,6 +2390,7 @@ async fn jv_track(args: TrackFileArgs) {
created,
updated,
synced,
+ skipped,
} => {
println!(
"{}",
@@ -2395,6 +2402,23 @@ async fn jv_track(args: TrackFileArgs) {
synced = synced.len()
))
);
+
+ if skipped.len() > 0 {
+ println!(
+ "\n{}",
+ md(t!(
+ "jv.result.track.tip_has_skipped",
+ skipped_num = skipped.len(),
+ skipped = skipped
+ .iter()
+ .map(|f| f.display().to_string())
+ .collect::<Vec<String>>()
+ .join("\n")
+ .trim()
+ ))
+ .yellow()
+ );
+ }
}
TrackFileActionResult::AuthorizeFailed(e) => {
eprintln!("{}", md(t!("jv.result.common.authroize_failed", err = e)))