Fix Elsewhen migration for dev checkouts
This commit is contained in:
1 parent
45748a2812
commit
0d5232ed7b
2 files changed
+24
-5
No files matched your search
@@ -2,5 +2,13 @@ echo "Install Elsewhen, the world clock plugin"
|
|||||||
|
|
||||||
omarchy-pkg-add elsewhen
|
omarchy-pkg-add elsewhen
|
||||||
|
|
||||||
|
# Dev checkouts do not contain plugins installed by system packages.
|
||||||
|
packaged_plugin="/usr/share/omarchy/shell/plugins/omacom.elsewhen"
|
||||||
|
user_plugin="$HOME/.config/omarchy/plugins/omacom.elsewhen"
|
||||||
|
if [[ ! $OMARCHY_PATH -ef /usr/share/omarchy && -d $packaged_plugin && ! -e $user_plugin && ! -L $user_plugin ]]; then
|
||||||
|
mkdir -p "${user_plugin%/*}"
|
||||||
|
ln -s "$packaged_plugin" "$user_plugin"
|
||||||
|
fi
|
||||||
|
|
||||||
omarchy-shell shell rescanPlugins
|
omarchy-shell shell rescanPlugins
|
||||||
omarchy-bar put omacom.elsewhen --before omarchy.clock
|
omarchy-bar put omacom.elsewhen --before omarchy.clock
|
||||||
@@ -28,11 +28,14 @@ exit 1
|
|||||||
SH
|
SH
|
||||||
chmod +x "$test_dir/bin/"*
|
chmod +x "$test_dir/bin/"*
|
||||||
|
|
||||||
|
mkdir -p "$test_dir/packaged/shell/plugins/omacom.elsewhen"
|
||||||
|
sed "s|/usr/share/omarchy|$test_dir/packaged|g" "$ROOT/migrations/1789581661.sh" >"$test_dir/migration.sh"
|
||||||
|
|
||||||
plugin="$test_dir/home/.config/omarchy/plugins/omacom.elsewhen"
|
plugin="$test_dir/home/.config/omarchy/plugins/omacom.elsewhen"
|
||||||
run_migration() {
|
run_migration() {
|
||||||
: >"$CALL_LOG"
|
: >"$CALL_LOG"
|
||||||
HOME="$test_dir/home" OMARCHY_PATH="$ROOT" PATH="$test_dir/bin:$ROOT/bin:$PATH" \
|
HOME="$test_dir/home" OMARCHY_PATH="${1:-$test_dir/packaged}" PATH="$test_dir/bin:$ROOT/bin:$PATH" \
|
||||||
bash -euo pipefail "$ROOT/migrations/1789581661.sh" >"$test_dir/output" 2>&1
|
bash -euo pipefail "$test_dir/migration.sh" >"$test_dir/output" 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
if PACKAGE_STATUS=1 run_migration; then
|
if PACKAGE_STATUS=1 run_migration; then
|
||||||
@@ -56,22 +59,30 @@ run_migration
|
|||||||
[[ ! -e $plugin && ! -L $plugin ]] || fail "rerunning the migration does not create a user plugin link"
|
[[ ! -e $plugin && ! -L $plugin ]] || fail "rerunning the migration does not create a user plugin link"
|
||||||
pass "migration can be rerun without a user plugin link"
|
pass "migration can be rerun without a user plugin link"
|
||||||
|
|
||||||
|
run_migration "$ROOT"
|
||||||
|
[[ $(readlink "$plugin") == "$test_dir/packaged/shell/plugins/omacom.elsewhen" ]] || fail "dev checkout links the packaged plugin"
|
||||||
|
pass "dev checkout discovers Elsewhen through a user plugin link"
|
||||||
|
run_migration "$ROOT"
|
||||||
|
[[ $(readlink "$plugin") == "$test_dir/packaged/shell/plugins/omacom.elsewhen" ]] || fail "dev link survives a rerun"
|
||||||
|
pass "dev link is idempotent"
|
||||||
|
rm "$plugin"
|
||||||
|
|
||||||
mkdir -p "$plugin"
|
mkdir -p "$plugin"
|
||||||
printf 'local work\n' >"$plugin/notes"
|
printf 'local work\n' >"$plugin/notes"
|
||||||
run_migration
|
run_migration "$ROOT"
|
||||||
[[ ! -L $plugin && $(cat "$plugin/notes") == "local work" ]] || fail "existing checkout is preserved"
|
[[ ! -L $plugin && $(cat "$plugin/notes") == "local work" ]] || fail "existing checkout is preserved"
|
||||||
pass "existing checkout and local files are preserved"
|
pass "existing checkout and local files are preserved"
|
||||||
|
|
||||||
rm "$plugin/notes"
|
rm "$plugin/notes"
|
||||||
rmdir "$plugin"
|
rmdir "$plugin"
|
||||||
ln -s "$test_dir/custom-plugin" "$plugin"
|
ln -s "$test_dir/custom-plugin" "$plugin"
|
||||||
run_migration
|
run_migration "$ROOT"
|
||||||
[[ $(readlink "$plugin") == "$test_dir/custom-plugin" ]] || fail "existing symlink is preserved"
|
[[ $(readlink "$plugin") == "$test_dir/custom-plugin" ]] || fail "existing symlink is preserved"
|
||||||
pass "existing symlink is preserved, including a missing target"
|
pass "existing symlink is preserved, including a missing target"
|
||||||
|
|
||||||
for failure in 'SCAN_STATUS=1' 'TEST_PUT_RESULT=unknown'; do
|
for failure in 'SCAN_STATUS=1' 'TEST_PUT_RESULT=unknown'; do
|
||||||
if env "$failure" HOME="$test_dir/home" OMARCHY_PATH="$ROOT" PATH="$test_dir/bin:$ROOT/bin:$PATH" \
|
if env "$failure" HOME="$test_dir/home" OMARCHY_PATH="$ROOT" PATH="$test_dir/bin:$ROOT/bin:$PATH" \
|
||||||
bash -euo pipefail "$ROOT/migrations/1789581661.sh" >"$test_dir/output" 2>&1; then
|
bash -euo pipefail "$test_dir/migration.sh" >"$test_dir/output" 2>&1; then
|
||||||
fail "$failure must leave the migration pending"
|
fail "$failure must leave the migration pending"
|
||||||
fi
|
fi
|
||||||
pass "$failure leaves the migration pending"
|
pass "$failure leaves the migration pending"
|
||||||
|
|||||||
Reference in new issue
Block a user