diff --git a/bin/omarchy-channel-set b/bin/omarchy-channel-set index f347317b..6a5c018f 100755 --- a/bin/omarchy-channel-set +++ b/bin/omarchy-channel-set @@ -55,7 +55,10 @@ validate_dev_region() { [[ -f $region_file ]] && region=$(<"$region_file") [[ $region == "global" ]] && return 0 - if [[ ! -f $checkout/bin/omarchy-apply-pacman || ! -d $checkout/default/regions/$region ]]; then + # The refresh after linking needs a runnable helper and both fragments, not + # just a directory with the region's name. + local profile="$checkout/default/regions/$region/pacman" + if [[ ! -x $checkout/bin/omarchy-apply-pacman || ! -r $profile/pacman.conf.append || ! -r $profile/mirrorlist.append ]]; then fail "$checkout does not support the '$region' region, so switching would drop its package repositories. Check out a branch with default/regions/$region, or remove $region_file to use global defaults." fi } diff --git a/test/shell.d/channel-test.sh b/test/shell.d/channel-test.sh index 7872c6f7..72418727 100644 --- a/test/shell.d/channel-test.sh +++ b/test/shell.d/channel-test.sh @@ -201,8 +201,29 @@ if grep -Eq $'^(link|refresh)\t' "$log_file"; then fi pass "dev refuses a checkout without the region before touching pacman" +# A directory with the region's name, or a helper that cannot run, is not +# support: the refresh after linking would fail with dev already linked. mkdir -p "$checkout/default/regions/cn" touch "$checkout/bin/omarchy-apply-pacman" +chmod +x "$checkout/bin/omarchy-apply-pacman" +if OMARCHY_TEST_REGION_FILE="$test_tmp/region" run_channel dev >"$test_tmp/region.out" 2>"$test_tmp/region.err"; then + fail "dev refuses an empty region profile" +fi +if grep -Eq $'^(link|refresh)\t' "$log_file"; then + fail "dev refuses an empty region profile before linking or refreshing pacman" "$(cat "$log_file")" +fi +mkdir -p "$checkout/default/regions/cn/pacman" +touch "$checkout/default/regions/cn/pacman/pacman.conf.append" "$checkout/default/regions/cn/pacman/mirrorlist.append" +chmod -x "$checkout/bin/omarchy-apply-pacman" +if OMARCHY_TEST_REGION_FILE="$test_tmp/region" run_channel dev >"$test_tmp/region.out" 2>"$test_tmp/region.err"; then + fail "dev refuses a checkout whose pacman helper cannot run" +fi +if grep -Eq $'^(link|refresh)\t' "$log_file"; then + fail "dev refuses incomplete region support before linking or refreshing pacman" "$(cat "$log_file")" +fi +pass "dev refuses an empty region profile or a helper that cannot run" + +chmod +x "$checkout/bin/omarchy-apply-pacman" OMARCHY_TEST_REGION_FILE="$test_tmp/region" run_channel dev assert_log_line $'refresh\tedge' "dev proceeds with a checkout that supports the region"