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
4 changes: 4 additions & 0 deletions bin/omarchy-update
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ source "${security_entrypoint%/*}/omarchy-security-functions" || exit 126
omarchy_security_require_privileged_bash_startup || exit 126
set -e
omarchy_security_sanitize_bash_environment "$0" "$@"
# pkexec strips the login environment before this entry point runs. A dev
# checkout already exports its own root; packaged installs use this path.
# The source-root check below still rejects any other value.
export OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}"
omarchy_security_require_source_root "$0"
# Logging and lock acquisition re-exec this command with a sanitized PATH.
# Preserve the caller's path only for the later hook/mise phases.
Expand Down
2 changes: 2 additions & 0 deletions bin/omarchy-update-dev
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

set -euo pipefail

OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}"
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved

[[ $OMARCHY_PATH != "/usr/share/omarchy" ]] || exit 0

if ! git -C "$OMARCHY_PATH" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
Expand Down
6 changes: 5 additions & 1 deletion bin/omarchy-update-mise
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@ if omarchy-cmd-present mise; then
# mise withholds releases younger than its cooldown, so tools stay behind for
# days after they ship. Running omarchy update is the user asking for current
# versions now, which is the same call the mup alias makes by hand.
MISE_MINIMUM_RELEASE_AGE=0 mise up
mise_up=(mise up)
if [[ ${OMARCHY_UPDATE_UNATTENDED:-} == 1 ]]; then
mise_up=(mise up --yes)
fi
MISE_MINIMUM_RELEASE_AGE=0 "${mise_up[@]}"
fi
16 changes: 16 additions & 0 deletions test/shell.d/update-dev-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ grep -F "OMARCHY_PATH is not a git checkout: $checkout" "$test_tmp/invalid.err"
fail "invalid dev checkout reports the configured path" "$(cat "$test_tmp/invalid.err")"
pass "invalid dev checkout fails with a useful error"

: >"$git_log"
if ! env -u OMARCHY_PATH PATH="$stub_bin:$PATH" "$ROOT/bin/omarchy-update-dev" >"$test_tmp/unset.out" 2>"$test_tmp/unset.err"; then
fail "unset OMARCHY_PATH should skip like the packaged install" "$(cat "$test_tmp/unset.err")"
fi
[[ ! -s $git_log ]] || fail "unset OMARCHY_PATH does not invoke git" "$(cat "$git_log")"
pass "unset OMARCHY_PATH defaults to the packaged install and skips git"

grep -qE '^ *omarchy-update-dev$' "$ROOT/bin/omarchy-update" ||
fail "top-level update includes the dev checkout step"
pass "top-level update includes the dev checkout step"

# The source-root check runs in omarchy-update, before omarchy-update-dev.
# pkexec omarchy-update -y arrives with OMARCHY_PATH unset, so the default
# has to be established here or the check exits before the helper runs.
default_line=$(grep -n 'export OMARCHY_PATH="${OMARCHY_PATH:-/usr/share/omarchy}"' "$ROOT/bin/omarchy-update" | head -1 | cut -d: -f1)
check_line=$(grep -n 'omarchy_security_require_source_root' "$ROOT/bin/omarchy-update" | head -1 | cut -d: -f1)
[[ -n $default_line && -n $check_line && $default_line -lt $check_line ]] ||

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 Numeric comparison breaks required style

The new condition uses -lt inside [[ ]]. AGENTS.md requires numeric comparisons to use (( )). If this assertion is retained, move the comparison of default_line and check_line into an arithmetic condition before merging.

Suggested change
[[ -n $default_line && -n $check_line && $default_line -lt $check_line ]] ||
[[ -n $default_line && -n $check_line ]] && (( default_line < check_line )) ||

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!

fail "update entry point defaults OMARCHY_PATH before the source-root check"
Comment on lines +121 to +124

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 Test only checks source text

The new assertion greps for the exact assignment instead of running omarchy-update with OMARCHY_PATH unset. It can pass even if the entry point still fails. AGENTS.md explicitly forbids tests that restate source edits. Before merging, replace this check with a test that exercises the entry point and checks its behavior.

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!

pass "update entry point defaults OMARCHY_PATH before the source-root check"
39 changes: 39 additions & 0 deletions test/shell.d/update-mise-unattended-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

set -euo pipefail

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

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 Update tests are unnecessarily split

This adds a separate test file even though update-sequence-test.sh already covers omarchy-update-mise. AGENTS.md requires extending the area's existing tests rather than adding another *-test.sh. Before merging, move these argument checks into the existing update tests.

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!


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

stub_bin="$test_tmp/bin"
mise_log="$test_tmp/mise.log"
mkdir -p "$stub_bin"

cat >"$stub_bin/mise" <<'SH'
#!/bin/bash
printf '%s\n' "$*" >>"$TEST_MISE_LOG"
SH
chmod +x "$stub_bin/mise"

cat >"$stub_bin/omarchy-cmd-present" <<'SH'
#!/bin/bash
[[ $1 == mise ]]
SH
chmod +x "$stub_bin/omarchy-cmd-present"

run_mise_update() {
: >"$mise_log"
TEST_MISE_LOG="$mise_log" PATH="$stub_bin:$PATH" "$@" "$ROOT/bin/omarchy-update-mise"
}

run_mise_update env -u OMARCHY_UPDATE_UNATTENDED
grep -Fx -- "up" "$mise_log" >/dev/null ||
fail "interactive update runs mise up without --yes" "$(cat "$mise_log")"
pass "interactive update runs mise up without --yes"

run_mise_update env OMARCHY_UPDATE_UNATTENDED=1
grep -Fx -- "up --yes" "$mise_log" >/dev/null ||
fail "unattended update passes --yes to mise up" "$(cat "$mise_log")"
pass "unattended update passes --yes to mise up"
Loading