feat(install): конфликтующие файлы бэкапятся перед stow для всех пакетов
- Зачем:
- конфликт с уже существующим конфигом приходилось разбирать руками:
stow печатал "All operations aborted" и откатывал все пакеты сразу.
- Что:
- backup_conflicting_kitty_files заменена на общую
backup_conflicting_stow_targets по списку AVAILABLE_PACKAGES.
- обход повторяет логику stow: отсутствующая цель и каталоги-симлинки
пропускаются вместе с поддеревом, поэтому свёрнутые пакеты
(~/.codex, ~/.vscode-server) не обходятся и не бэкапятся.
- в фикстуру тестов добавлен пакет wezterm, добавлены тесты на конфликт
в HOME и на неприкосновенность содержимого свёрнутого пакета.
- Проверка:
- bash tests/test_install.sh
This commit is contained in:
1 parent
6610adeac5
commit
c6d7e7eeb0
2 files changed
+83
-16
No files matched your search
+38
-1
@@ -37,7 +37,7 @@ setup_fixture() {
|
||||
# zed/.config/opencode и т.п.) весят гигабайты, переполняют /tmp и ломают
|
||||
# stow конфликтами, поэтому в тестовое дерево не попадает.
|
||||
git -C "$REPO_ROOT" ls-files -z --cached -- \
|
||||
install.sh bash tmux vim zed kitty vscode agents opencode codex gemini \
|
||||
install.sh bash tmux vim zed kitty wezterm vscode agents opencode codex gemini \
|
||||
claude proxy-client scripts \
|
||||
| tar -C "$REPO_ROOT" --null -T - -cf - \
|
||||
| tar -xf - -C "$repo_root"
|
||||
@@ -200,6 +200,41 @@ test_rerun_does_not_backup_managed_kitty_config() {
|
||||
[ -z "$backup" ] || fail "Rerun must not create backups of its own symlinks: $backup"
|
||||
}
|
||||
|
||||
test_existing_wezterm_config_is_backed_up() {
|
||||
local fixture repo_root home_dir backup
|
||||
fixture="$(setup_fixture)"
|
||||
repo_root="$fixture/repo"
|
||||
home_dir="$fixture/home"
|
||||
mkdir -p "$home_dir"
|
||||
# Тот же конфликт, но у пакета с файлом прямо в HOME, а не в ~/.config.
|
||||
printf '%s\n' 'local wezterm = require("wezterm")' > "$home_dir/.wezterm.lua"
|
||||
|
||||
run_install "$repo_root" "$home_dir" env WSL_DISTRO_NAME= INSTALL_INTERACTIVE_MODE=never >"$fixture/install.out"
|
||||
|
||||
[ -L "$home_dir/.wezterm.lua" ] || fail "Expected managed .wezterm.lua symlink"
|
||||
backup="$(find "$home_dir" -maxdepth 1 -name '.wezterm.lua.bak.*' -print -quit)"
|
||||
[ -n "$backup" ] || fail "Expected backup of the pre-existing .wezterm.lua"
|
||||
assert_file_contains "$backup" 'require("wezterm")'
|
||||
}
|
||||
|
||||
test_folded_package_runtime_files_are_not_backed_up() {
|
||||
local fixture repo_root home_dir backup
|
||||
fixture="$(setup_fixture)"
|
||||
repo_root="$fixture/repo"
|
||||
home_dir="$fixture/home"
|
||||
mkdir -p "$home_dir"
|
||||
|
||||
run_install "$repo_root" "$home_dir" env WSL_DISTRO_NAME= INSTALL_INTERACTIVE_MODE=never >"$fixture/install.out"
|
||||
# ~/.codex свёрнут в симлинк на пакет: файлы внутри — уже наши, не конфликт.
|
||||
printf '%s\n' '{}' > "$home_dir/.codex/auth.json"
|
||||
|
||||
run_install "$repo_root" "$home_dir" env WSL_DISTRO_NAME= INSTALL_INTERACTIVE_MODE=never >"$fixture/install2.out"
|
||||
|
||||
backup="$(find "$repo_root" "$home_dir" -name '*.bak.*' -print -quit)"
|
||||
[ -z "$backup" ] || fail "Folded package contents must not be backed up: $backup"
|
||||
assert_file_contains "$home_dir/.codex/auth.json" "{}"
|
||||
}
|
||||
|
||||
test_migrates_legacy_zed_config_symlink() {
|
||||
local fixture repo_root home_dir legacy_config output mode
|
||||
fixture="$(setup_fixture)"
|
||||
@@ -599,6 +634,8 @@ main() {
|
||||
test_existing_kitty_config_is_backed_up_and_does_not_abort_stow
|
||||
test_foreign_kitty_config_symlink_is_backed_up
|
||||
test_rerun_does_not_backup_managed_kitty_config
|
||||
test_existing_wezterm_config_is_backed_up
|
||||
test_folded_package_runtime_files_are_not_backed_up
|
||||
test_migrates_legacy_zed_config_symlink
|
||||
test_stops_legacy_migration_when_listing_fails
|
||||
test_does_not_migrate_unrelated_config_symlink
|
||||
|
||||
Reference in new issue
Block a user