Repository navigation
Restore missing mise stubs from the canonical install list #13781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: quattro
Are you sure you want to change the base?
Changes from all commits
6cffc58
ac4228d
9e97449
ce45d6f
5f9188d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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() { :; } | ||
|
|
||
| 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" | ||
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This adds a test specifically for Remove this suite test. If the repair needs reusable logic worth testing, move that logic into a File Used: 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" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mise() { :; }disables every action in the currentinstall/user/mise.sh. That file only callsmise reshim --systemandmise reshim; it never callsomarchy-mise-install. The migration therefore restores nothing but returns success, soomarchy-migratemarks the repair complete. The added test also fails its firstghcheck.Update the migration to use the current way mise creates missing commands instead of disabling it.