diff --git a/migrations/1785002349.sh b/migrations/1785002349.sh new file mode 100644 index 00000000..3b3bb998 --- /dev/null +++ b/migrations/1785002349.sh @@ -0,0 +1,22 @@ +echo "Repair Neovim theme symlinks the earlier relink missed" + +theme_link="$HOME/.config/nvim/lua/plugins/theme.lua" +current_absolute_target="$HOME/.local/state/omarchy/current/theme/neovim.lua" +current_relative_target="../../../../.local/state/omarchy/current/theme/neovim.lua" + +[[ -L $theme_link ]] || exit 0 + +target=$(readlink "$theme_link") || exit 0 + +# Already pointing at the state directory. +[[ $target == "$current_relative_target" || $target == "$current_absolute_target" ]] && exit 0 + +# 1781158082.sh matched an explicit list of legacy spellings and missed at least +# one ("../../../../.config/omarchy/current/theme/neovim.lua"), leaving those +# links dangling. Match the shared suffix instead so every spelling is repaired. +case "$target" in + */omarchy/current/theme/neovim.lua) ;; + *) exit 0 ;; +esac + +ln -sfn "$current_relative_target" "$theme_link" diff --git a/test/cli b/test/cli index f192b7ec..7b822d27 100755 --- a/test/cli +++ b/test/cli @@ -423,6 +423,28 @@ for nvim_legacy_target in \ done pass "nvim theme migration relinks current theme" +for nvim_legacy_target in \ + "../../../omarchy/current/theme/neovim.lua" \ + "../../../../.config/omarchy/current/theme/neovim.lua" \ + "~/.config/omarchy/current/theme/neovim.lua" \ + "$NVIM_MIGRATION_TMPDIR/.config/omarchy/current/theme/neovim.lua"; do + ln -sfn "$nvim_legacy_target" "$nvim_theme_link" + HOME="$NVIM_MIGRATION_TMPDIR" bash -euo pipefail "$ROOT/migrations/1785002349.sh" >/dev/null + nvim_actual_target=$(readlink "$nvim_theme_link") + nvim_resolved_target=$(readlink -f "$nvim_theme_link") + [[ $nvim_actual_target == $nvim_expected_target ]] || fail "nvim theme repair migration updates $nvim_legacy_target" + [[ $nvim_resolved_target == $nvim_expected_resolved_target ]] || fail "nvim theme repair migration points to current theme" +done + +HOME="$NVIM_MIGRATION_TMPDIR" bash -euo pipefail "$ROOT/migrations/1785002349.sh" >/dev/null +[[ $(readlink "$nvim_theme_link") == $nvim_expected_target ]] || fail "nvim theme repair migration is idempotent" + +touch "$NVIM_MIGRATION_TMPDIR/custom-theme.lua" +ln -sfn "../../../../custom-theme.lua" "$nvim_theme_link" +HOME="$NVIM_MIGRATION_TMPDIR" bash -euo pipefail "$ROOT/migrations/1785002349.sh" >/dev/null +[[ $(readlink "$nvim_theme_link") == "../../../../custom-theme.lua" ]] || fail "nvim theme repair migration leaves custom symlinks alone" +pass "nvim theme repair migration relinks every legacy spelling" + HYPR_MIGRATION_TMPDIR=$(mktemp -d) mkdir -p "$HYPR_MIGRATION_TMPDIR/.config/hypr" cat >"$HYPR_MIGRATION_TMPDIR/.config/hypr/hyprland.lua" <<'LUA'