Skip to content
Closed
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
8 changes: 6 additions & 2 deletions bin/omarchy-plugin-clone
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions test/shell.d/plugin-clone-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"