Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions migrations/1790712217.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
echo "Restore missing mise stubs from the canonical install list"

# 1784909971.sh rewrote wrappers by walking ~/.local/bin. Once that directory
# is empty the glob matches nothing, so later updates never recreate gh and
# the other documented lazy stubs.
#
# Only recreate stubs that are actually missing, and skip the whole list when
# the user already ran omarchy-remove-preinstalls (preinstalls-removed).

mise_leaf="${OMARCHY_PATH:-/usr/share/omarchy}/install/user/mise.sh"

if [[ -f $HOME/.local/state/omarchy/preinstalls-removed ]]; then
echo "preinstalls-removed is set; leaving removed stubs alone"
exit 0
fi

mise() { :; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 The repair does nothing

mise() { :; } disables every action in the current install/user/mise.sh. That file only calls mise reshim --system and mise reshim; it never calls omarchy-mise-install. The migration therefore restores nothing but returns success, so omarchy-migrate marks the repair complete. The added test also fails its first gh check.

Update the migration to use the current way mise creates missing commands instead of disabling it.


omarchy-mise-install() {
local command=${2:-$1}

# -e is false for a dangling symlink. A user-owned launcher with a missing
# target must still be left alone; only a truly absent path gets a stub.
if [[ -e $HOME/.local/bin/$command || -L $HOME/.local/bin/$command ]]; then
return 0
fi

command omarchy-mise-install "$@"
}

# shellcheck disable=SC1090
source "$mise_leaf"
57 changes: 57 additions & 0 deletions test/shell.d/mise-stub-restore-migration-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

set -euo pipefail

source "$(dirname "${BASH_SOURCE[0]}")/base-test.sh"

migration="$ROOT/migrations/1790712217.sh"
[[ -f $migration ]] || fail "the restore migration is present"
Comment on lines +7 to +8

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Migration tests break repository rules

This adds a test specifically for 1790712217.sh. AGENTS.md explicitly says not to add migration tests because migrations run once and are frozen after shipping. This repository requirement must be satisfied before merging.

Remove this suite test. If the repair needs reusable logic worth testing, move that logic into a bin/ command and test the command instead.

File Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT

home="$tmpdir/home"
mkdir -p "$home/.local/bin" "$home/.local/state/omarchy"

run() {
env HOME="$home" OMARCHY_PATH="$ROOT" PATH="$ROOT/bin:$PATH" \
bash -euo pipefail "$migration"
}

run
[[ -x $home/.local/bin/gh ]] || fail "an empty ~/.local/bin gets the gh stub back"
[[ -x $home/.local/bin/codex ]] || fail "an empty ~/.local/bin gets the other canonical stubs"
pass "wiping ~/.local/bin restores gh from the canonical list"

printf 'user-owned\n' >"$home/.local/bin/gh"
run
[[ $(cat "$home/.local/bin/gh") == user-owned ]] || fail "an existing gh stub is left alone"
pass "existing files are not overwritten"

ln -sfn /nonexistent/user-launcher "$home/.local/bin/claude"
run
[[ -L $home/.local/bin/claude ]] || fail "a dangling user-owned launcher stays a symlink"
[[ $(readlink "$home/.local/bin/claude") == /nonexistent/user-launcher ]] || fail "a dangling user-owned launcher is not replaced"
pass "dangling user-owned launchers are left alone"

[[ -x $home/.local/bin/codex ]] || fail "a second run still leaves stubs that were already restored"
pass "the restore is idempotent"

touch "$home/.local/state/omarchy/preinstalls-removed"
rm -f "$home/.local/bin/"*
run
[[ ! -e $home/.local/bin/gh && ! -L $home/.local/bin/gh ]] || fail "preinstalls-removed does not restore gh"
[[ ! -e $home/.local/bin/codex && ! -L $home/.local/bin/codex ]] || fail "preinstalls-removed does not restore other stubs"
[[ ! -e $home/.local/bin/hey && ! -L $home/.local/bin/hey ]] || fail "preinstalls-removed does not restore hey"
pass "removed preinstalls stay removed"

# A migration that cannot finish must fail and stay pending. A fresh home, so
# the preinstalls-removed exit cannot pass this on its own.
missing=$(mktemp -d)
mkdir -p "$missing/home/.local/bin"
if env HOME="$missing/home" OMARCHY_PATH="$missing" PATH="$ROOT/bin:$PATH" \
bash -euo pipefail "$migration" 2>/dev/null; then
fail "a missing mise install list fails the migration"
fi
pass "a missing mise install list leaves the migration pending"
rm -rf "$missing"
Loading