feat: add option to ignore conflicting files (#1613)

This commit is contained in:
Celestial.y
2025-07-25 08:58:39 +08:00
committed by GitHub
+17 -3
View File
@@ -203,10 +203,11 @@ handle_file_conflict() {
echo "4) Save repository version as ${filename}.new, keep local file" echo "4) Save repository version as ${filename}.new, keep local file"
echo "5) Show diff and decide" echo "5) Show diff and decide"
echo "6) Skip this file" echo "6) Skip this file"
echo "7) Add to ignore and skip"
echo echo
while true; do 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 echo
log_warning "Failed to read input. Skipping file." log_warning "Failed to read input. Skipping file."
return return
@@ -242,8 +243,9 @@ handle_file_conflict() {
echo "b) Backup local and use repository version" echo "b) Backup local and use repository version"
echo "n) Save repository version as .new" echo "n) Save repository version as .new"
echo "s) Skip this file" 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 echo
log_warning "Failed to read input. Skipping file." log_warning "Failed to read input. Skipping file."
return return
@@ -274,6 +276,12 @@ handle_file_conflict() {
log_info "Skipping $home_file" log_info "Skipping $home_file"
break 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." echo "Invalid choice. Please try again."
;; ;;
@@ -283,8 +291,14 @@ handle_file_conflict() {
log_info "Skipping $home_file" log_info "Skipping $home_file"
break 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 esac
done done