Repository navigation
Let omarchy update also update plugins, as an opt-in toggle, and let one plugin be held back #18868
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
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,26 @@ | ||
| #!/bin/bash | ||
|
|
||
| # omarchy:summary=Keep a plugin out of updates that do not name it | ||
| # omarchy:group=plugin | ||
| # omarchy:args=<id> | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| fail() { | ||
| echo "omarchy-plugin-hold: $*" >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| if [[ ${1:-} == "-h" || ${1:-} == "--help" ]]; then | ||
| echo "Usage: omarchy plugin hold <id>" | ||
| exit 0 | ||
| fi | ||
|
|
||
| id="${1:-}" | ||
| [[ -n $id ]] || fail "plugin id is required" | ||
| [[ $id =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ && $id != *..* ]] || fail "invalid plugin id '$id'" | ||
|
|
||
| held_dir="$HOME/.local/state/omarchy/plugins/held" | ||
| mkdir -p "$held_dir" && : >"$held_dir/$id" | ||
|
|
||
| echo "Held $id: plugin updates skip it until: omarchy plugin unhold $id" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #!/bin/bash | ||
|
|
||
| # omarchy:summary=Let a held plugin update again | ||
| # omarchy:group=plugin | ||
| # omarchy:args=<id> | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| fail() { | ||
| echo "omarchy-plugin-unhold: $*" >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| if [[ ${1:-} == "-h" || ${1:-} == "--help" ]]; then | ||
| echo "Usage: omarchy plugin unhold <id>" | ||
| exit 0 | ||
| fi | ||
|
|
||
| id="${1:-}" | ||
| [[ -n $id ]] || fail "plugin id is required" | ||
| [[ $id =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ && $id != *..* ]] || fail "invalid plugin id '$id'" | ||
|
|
||
| held_dir="$HOME/.local/state/omarchy/plugins/held" | ||
| rm -f "$held_dir/$id" | ||
|
|
||
| echo "Unheld $id" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,8 @@ export GIT_TERMINAL_PROMPT=0 | |
| export GIT_SSH_COMMAND="${GIT_SSH_COMMAND:-ssh -oBatchMode=yes}" | ||
|
|
||
| PLUGINS_DIR="$HOME/.config/omarchy/plugins" | ||
| # Plugins held with omarchy plugin hold, skipped unless named. | ||
| HELD_DIR="$HOME/.local/state/omarchy/plugins/held" | ||
| ASSUME_YES=0 | ||
| UPDATED_ANY=0 | ||
|
|
||
|
|
@@ -114,7 +116,12 @@ if [[ -n $id ]]; then | |
| else | ||
| for dir in "$PLUGINS_DIR"/*/; do | ||
| [[ -d $dir/.git ]] || continue | ||
| targets+=("$(basename "$dir")") | ||
| plugin=$(basename "$dir") | ||
| if [[ -f $HELD_DIR/$plugin ]]; then | ||
|
Comment on lines
+119
to
+120
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. The hold check uses the folder name instead of the manifest's |
||
| echo "$plugin is held back; run: omarchy plugin unhold $plugin" | ||
| continue | ||
| fi | ||
| targets+=("$plugin") | ||
| done | ||
| if (( ${#targets[@]} == 0 )); then | ||
| echo "No git-managed plugins installed." | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,6 +127,19 @@ if [[ ${1:-} == "-y" ]] || omarchy-update-confirm; then | |
| omarchy-done mark first-update | ||
| omarchy-shell -q omarchy.system-update clear | ||
|
|
||
| # Plugins are third-party code, so updating them here is opt-in | ||
| # (omarchy-toggle update-plugins). The shell restart below loads what changed. | ||
| if omarchy-toggle-enabled update-plugins; then | ||
| if [[ ${OMARCHY_UPDATE_UNATTENDED:-} == "1" ]]; then | ||
| plugin_update_args=(--yes) | ||
| else | ||
| plugin_update_args=() | ||
| fi | ||
| if ! omarchy-plugin-update "${plugin_update_args[@]}"; then | ||
| echo -e "\e[33m\nSome plugins could not be updated. Review the errors above and run 'omarchy plugin update' to retry.\e[0m" >&2 | ||
|
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. The new plugin failure warning prints English directly. The repository requires warnings from 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! |
||
| fi | ||
| fi | ||
|
|
||
| # Service restart helpers can need sudo. The reboot-only phase below | ||
| # performs no privileged work. | ||
| omarchy-update-restart --services-only | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" | ||
|
|
||
| TMPDIR=$(mktemp -d) | ||
| trap 'rm -rf "$TMPDIR"' EXIT | ||
| mkdir -p "$TMPDIR/bin" | ||
| home="$TMPDIR/home" | ||
| calls="$TMPDIR/calls" | ||
| for id in alpha.one beta.two; do | ||
| mkdir -p "$home/.config/omarchy/plugins/$id/.git" | ||
| done | ||
|
|
||
| # git reports every plugin up to date and records which one it was asked about. | ||
| cat >"$TMPDIR/bin/git" <<'SH' | ||
| #!/bin/bash | ||
| [[ $1 == "-C" ]] && printf '%s %s\n' "${2##*/}" "$3" >>"$OMARCHY_TEST_CALLS" | ||
| [[ $3 == "rev-parse" ]] && echo same | ||
| exit 0 | ||
| SH | ||
| chmod +x "$TMPDIR/bin/git" | ||
|
|
||
| run() { | ||
| HOME="$home" OMARCHY_PATH="$ROOT" OMARCHY_TEST_CALLS="$calls" \ | ||
| PATH="$TMPDIR/bin:$ROOT/bin:$PATH" "$@" | ||
| } | ||
|
|
||
| run omarchy-plugin-hold beta.two >/dev/null | ||
| [[ -f $home/.local/state/omarchy/plugins/held/beta.two ]] || fail "hold did not record the plugin" | ||
| pass "plugin hold records the plugin" | ||
|
|
||
| : >"$calls" | ||
| out=$(run omarchy-plugin-update --yes) | ||
| grep -q '^alpha.one fetch' "$calls" || fail "update skipped a plugin that is not held" | ||
| ! grep -q '^beta.two' "$calls" || fail "update touched a held plugin" | ||
| grep -Fq 'beta.two is held back' <<<"$out" || fail "update did not say the plugin is held" | ||
| pass "plugin update skips a held plugin and says so" | ||
|
|
||
| : >"$calls" | ||
| run omarchy-plugin-update beta.two --yes >/dev/null | ||
| grep -q '^beta.two fetch' "$calls" || fail "update by name did not update a held plugin" | ||
| pass "plugin update by name still updates a held plugin" | ||
|
|
||
| run omarchy-plugin-unhold beta.two >/dev/null | ||
| : >"$calls" | ||
| run omarchy-plugin-update --yes >/dev/null | ||
| grep -q '^beta.two fetch' "$calls" || fail "unhold did not let the plugin update again" | ||
| pass "plugin unhold lets it update again" | ||
|
|
||
| if run omarchy-plugin-hold '../evil' >/dev/null 2>&1; then | ||
| fail "hold accepted a path as a plugin id" | ||
| fi | ||
| pass "plugin hold rejects ids that are not plugin ids" |
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.
If
mkdir -pfails, Bash skips the file write but continues to the success message because the failed command is on the left of&&. The command then exits successfully without saving the hold, so later bulk updates can still change the plugin. Run directory creation and the file write as separate commands, or explicitly fail when either fails.