From 715aa8d8453c6d94e919fcfbdc8c4db755662e62 Mon Sep 17 00:00:00 2001 From: obsidrielle <1049617132@qq.com> Date: Fri, 11 Jul 2025 13:37:25 +0800 Subject: [PATCH] feat: add option to ignore conflicting files --- update.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/update.sh b/update.sh index 098a6a0fa..fa5036247 100755 --- a/update.sh +++ b/update.sh @@ -203,10 +203,11 @@ handle_file_conflict() { echo "4) Save repository version as ${filename}.new, keep local file" echo "5) Show diff and decide" echo "6) Skip this file" + echo "7) Add to ignore and skip" echo while true; do - if ! safe_read "Enter your choice (1-6): " choice "6"; then + if ! safe_read "Enter your choice (1-7): " choice "6"; then echo log_warning "Failed to read input. Skipping file." return @@ -242,8 +243,9 @@ handle_file_conflict() { echo "b) Backup local and use repository version" echo "n) Save repository version as .new" echo "s) Skip this file" + echo "i) Add to ignore and skip" - if ! safe_read "Enter your choice (r/k/b/n/s): " subchoice "s"; then + if ! safe_read "Enter your choice (r/k/b/n/s/i): " subchoice "s"; then echo log_warning "Failed to read input. Skipping file." return @@ -274,6 +276,12 @@ handle_file_conflict() { log_info "Skipping $home_file" break ;; + i) + local relative_path_to_home="${home_file#$HOME/}" + echo "$relative_path_to_home" >>"$HOME_UPDATE_IGNORE_FILE" + log_success "Added '$relative_path_to_home' to $HOME_UPDATE_IGNORE_FILE and skipped." + break + ;; *) echo "Invalid choice. Please try again." ;; @@ -283,8 +291,14 @@ handle_file_conflict() { log_info "Skipping $home_file" break ;; + 7) + local relative_path_to_home="${home_file#$HOME/}" + echo "$relative_path_to_home" >>"$HOME_UPDATE_IGNORE_FILE" + log_success "Added '$relative_path_to_home' to $HOME_UPDATE_IGNORE_FILE and skipped." + break + ;; *) - echo "Invalid choice. Please enter 1-6." + echo "Invalid choice. Please enter 1-7." ;; esac done