Link dev channel to home checkout

This commit is contained in:
David Heinemeier Hansson
2026-07-23 14:01:36 -07:00
parent e68b0f025d
commit f911851319
3 changed files with 39 additions and 81 deletions
+22 -41
View File
@@ -47,22 +47,9 @@ write_stub gum '#!/bin/bash
printf "gum" >>"$OMARCHY_CHANNEL_TEST_LOG"
for arg in "$@"; do printf "\t%s" "$arg" >>"$OMARCHY_CHANNEL_TEST_LOG"; done
printf "\n" >>"$OMARCHY_CHANNEL_TEST_LOG"
if [[ $1 == "input" ]]; then
printf "%s\n" "${OMARCHY_TEST_GUM_INPUT:-$HOME/Work/omarchy}"
fi
exit 0
'
write_stub omarchy-cmd-missing '#!/bin/bash
[[ $1 == "git" ]] && exit 1
exit 0
'
write_stub omarchy-cmd-present '#!/bin/bash
[[ $1 == "omarchy-dev-unlink" || $1 == "gum" || $1 == "git" ]] && exit 0
exit 1
'
write_stub git '#!/bin/bash
printf "git" >>"$OMARCHY_CHANNEL_TEST_LOG"
for arg in "$@"; do printf "\t%s" "$arg" >>"$OMARCHY_CHANNEL_TEST_LOG"; done
@@ -96,8 +83,6 @@ esac
run_channel() {
: >"$log_file"
OMARCHY_CHANNEL_TEST_LOG="$log_file" \
OMARCHY_DEV_PATH="${OMARCHY_DEV_PATH:-}" \
OMARCHY_TEST_GUM_INPUT="${OMARCHY_TEST_GUM_INPUT:-}" \
OMARCHY_PATH="$ROOT" \
HOME="$test_tmp/home" \
PATH="$stub_bin:$ROOT/bin:$PATH" \
@@ -112,17 +97,6 @@ assert_log_line() {
pass "$description"
}
assert_numbered_log_line() {
local number="$1"
local expected="$2"
local description="$3"
local actual=""
actual=$(sed -n "${number}p" "$log_file")
[[ $actual == $expected ]] || fail "$description" "$(cat "$log_file")"
pass "$description"
}
run_channel stable
assert_log_line $'refresh\tstable' "stable refreshes the stable pacman channel"
assert_log_line $'sudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--noconfirm\t--ask\t4\tomarchy\tomarchy-settings' "stable installs stable Omarchy packages"
@@ -141,20 +115,9 @@ assert_log_line $'sudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--no
assert_log_line 'unlink' "edge remains package-backed"
assert_log_line $'update\t-y' "edge runs the normal update pipeline"
checkout="$test_tmp/dev-checkout"
default_checkout="$test_tmp/home/Work/omarchy"
OMARCHY_TEST_GUM_INPUT="$checkout" run_channel dev
assert_numbered_log_line 1 $'gum\tconfirm\t--default=false\tEnable Dev anyway?' "dev warns before changing packages"
assert_numbered_log_line 2 $'gum\tinput\t--value\t'"$default_checkout"$'\t--placeholder\t'"$default_checkout"$'\t--header\tWhere should Dev checkout live? Existing non-checkout paths will not be overwritten.' "dev prompts for the checkout path before changing packages"
assert_log_line $'gum\tconfirm\t--default=false\tEnable Dev anyway?' "dev asks for confirmation"
assert_log_line $'refresh\tedge' "dev refreshes the edge pacman channel"
assert_log_line $'sudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--noconfirm\t--ask\t4\tomarchy-dev\tomarchy-settings-dev' "dev installs development Omarchy packages"
assert_log_line $'git\tclone\t--branch\tquattro\t--single-branch\thttps://github.com/basecamp/omarchy.git\t'"$checkout" "dev clones the quattro checkout"
assert_log_line $'link\t'"$checkout" "dev links the source checkout"
occupied_checkout="$test_tmp/occupied"
mkdir -p "$occupied_checkout"
if OMARCHY_TEST_GUM_INPUT="$occupied_checkout" run_channel dev >"$test_tmp/occupied.out" 2>"$test_tmp/occupied.err"; then
checkout="$test_tmp/home/omarchy"
mkdir -p "$checkout"
if run_channel dev >"$test_tmp/occupied.out" 2>"$test_tmp/occupied.err"; then
fail "dev refuses to use an occupied non-checkout path"
fi
@@ -164,6 +127,24 @@ if grep -Fx $'refresh\tedge' "$log_file" >/dev/null; then
fi
pass "dev refuses occupied non-checkout paths before package changes"
rmdir "$checkout"
run_channel dev
assert_log_line $'gum\tconfirm\t--default=false\tEnable Dev anyway?' "dev asks for confirmation"
assert_log_line $'refresh\tedge' "dev refreshes the edge pacman channel"
assert_log_line $'sudo\tenv\tOMARCHY_UPDATE_PACMAN=1\tpacman\t-S\t--needed\t--noconfirm\t--ask\t4\tomarchy-dev\tomarchy-settings-dev' "dev installs development Omarchy packages"
assert_log_line $'git\tclone\thttps://github.com/basecamp/omarchy.git\t'"$checkout" "dev clones the source checkout to ~/omarchy"
assert_log_line $'link\t'"$checkout" "dev links ~/omarchy"
run_channel stable
assert_log_line 'unlink' "switching from dev to stable unlinks the source checkout"
run_channel dev
if grep -q $'^git\tclone\t' "$log_file"; then
fail "dev reuses an existing checkout" "$(cat "$log_file")"
fi
assert_log_line $'link\t'"$checkout" "switching back to dev links ~/omarchy"
pass "switching back to dev reuses the existing ~/omarchy checkout"
current_channel() {
OMARCHY_TEST_VERSION_CHANNEL="$1" \
OMARCHY_TEST_PACKAGES="$2" \
@@ -182,4 +163,4 @@ pass "current channel detects rc"
pass "current channel detects package-backed edge"
[[ $(current_channel edge dev "$test_tmp/dev-checkout") == "dev" ]] || fail "current channel detects dev from OMARCHY_PATH"
pass "current channel detects dev from OMARCHY_PATH"
pass "current channel honors a dev link outside ~/omarchy"