From cc72846e4f08a50b5dcebacf66fd1b8b7f68423c Mon Sep 17 00:00:00 2001 From: sanjyay <102979855+sanjyay@users.noreply.github.com> Date: Mon, 21 Sep 2026 22:15:09 +0530 Subject: [PATCH] Avoid reserved omarchy.* namespace collision when cloning under omarchy username --- bin/omarchy-plugin-clone | 8 ++++++-- test/shell.d/plugin-clone-test.sh | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/bin/omarchy-plugin-clone b/bin/omarchy-plugin-clone index 59ca16172ed4..255c3c1a5c62 100755 --- a/bin/omarchy-plugin-clone +++ b/bin/omarchy-plugin-clone @@ -128,7 +128,11 @@ source_info=$(omarchy-plugin-catalog | jq -r --arg id "$source_id" ' [[ -n $source_info ]] || fail "unknown built-in plugin: $source_id" IFS=$'\t' read -r source_dir source_manifest source_name <<<"$source_info" -new_id="${USER:-$(id -un)}.${source_id#omarchy.}" +user_prefix="${USER:-$(id -un)}" +if [[ $user_prefix == "omarchy" || $user_prefix == omarchy.* ]]; then + user_prefix="local" +fi +new_id="$user_prefix.${source_id#omarchy.}" display_name="My $source_name" target_dir="$PLUGINS_DIR/$new_id" [[ ! -e $target_dir && ! -L $target_dir ]] || fail "$target_dir already exists" @@ -149,7 +153,7 @@ stage="" omarchy-shell shell rescanPlugins >/dev/null discovered=0 for (( attempt = 0; attempt < 40; attempt++ )); do - if omarchy-plugin-list --json | jq -e --arg id "$new_id" 'any(.[]; .id == $id)' >/dev/null; then + if omarchy-plugin-list --json | jq -e --arg id "$new_id" 'any(.[]; .id == $id and (.firstParty | not))' >/dev/null; then discovered=1 break fi diff --git a/test/shell.d/plugin-clone-test.sh b/test/shell.d/plugin-clone-test.sh index 2c9c815525ec..50fd545c96a3 100755 --- a/test/shell.d/plugin-clone-test.sh +++ b/test/shell.d/plugin-clone-test.sh @@ -191,3 +191,12 @@ fi [[ ! -e $TMPDIR/home/.config/omarchy/plugins/tester.osd ]] || fail "failed clone discovery leaves a partial clone behind" pass "clone removes a partial clone when switching fails" + +HOME="$TMPDIR/home" USER=omarchy OMARCHY_PATH="$ROOT" PATH="$TMPDIR/bin:$ROOT/bin:$PATH" \ + FAKE_CALLS="$CALLS" OMARCHY_TEST_ROOT="$ROOT" \ + omarchy-plugin-clone omarchy.clock >/dev/null +[[ -d $TMPDIR/home/.config/omarchy/plugins/local.clock ]] || + fail "clone under omarchy username does not use local prefix" +grep -qx 'omarchy-plugin-enable local.clock' "$CALLS" || + fail "clone under omarchy username does not enable local.clock" +pass "clone under omarchy username uses local prefix to avoid namespace collision"