From f713233eee9143d0a798976fd0d11609f91c0b5c Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Fri, 23 Oct 2026 03:47:21 +0000 Subject: fix(codex): accept linked git worktrees as checkouts package-codex-plugin.sh and sync-to-codex-plugin.sh checked for a checkout with [[ -d .git ]]. In a linked worktree .git is a file, so both scripts died with "not a git checkout" there, and tests/codex/test-package-codex-plugin.sh failed 9 checks when run from any worktree. Test that .git exists instead: it covers both layouts and still requires the path to be the root of a checkout, which matters for sync's user-supplied --local path. The scripts' later git commands already work in worktrees. Regression tests run the package script from a linked worktree of the repo, and a sync preview from a linked upstream worktree into a linked destination worktree. The package test is adapted from #1910. Co-authored-by: tianma-if Claude-Session: https://claude.ai/code/session_01SHANcr4A71nzuU9et4Fnba --- tests/codex/test-package-codex-plugin.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/codex/test-package-codex-plugin.sh') diff --git a/tests/codex/test-package-codex-plugin.sh b/tests/codex/test-package-codex-plugin.sh index 947cb6d..05e150a 100755 --- a/tests/codex/test-package-codex-plugin.sh +++ b/tests/codex/test-package-codex-plugin.sh @@ -9,6 +9,7 @@ FAILURES=0 TEST_ROOT="$(mktemp -d)" cleanup() { + git -C "$REPO_ROOT" worktree remove --force "$TEST_ROOT/linked-worktree" >/dev/null 2>&1 || true rm -rf "$TEST_ROOT" } trap cleanup EXIT @@ -138,6 +139,8 @@ archive="$TEST_ROOT/superpowers" tar_archive="$TEST_ROOT/superpowers.tar.gz" extracted="$TEST_ROOT/extracted" tar_extracted="$TEST_ROOT/tar-extracted" +worktree_archive="$TEST_ROOT/superpowers-from-worktree.zip" +linked_worktree="$TEST_ROOT/linked-worktree" write_metadata_fixture "$metadata_source" source_hooks="$(python3 -c 'import json; print(json.load(open("'"$REPO_ROOT"'/.codex-plugin/plugin.json")).get("hooks"))')" @@ -160,6 +163,25 @@ assert_contains "$output" "Archive:" "reports archive path" assert_contains "$output" "Format: zip" "reports default zip format" assert_contains "$output" "SHA-256:" "reports archive checksum" +if git -C "$REPO_ROOT" worktree add -q --detach "$linked_worktree" HEAD >/dev/null 2>&1; then + # The worktree is checked out at HEAD, so copy in the script under test + # (it may have uncommitted edits); that dirties the tree, hence --allow-dirty. + cp "$SCRIPT_UNDER_TEST" "$linked_worktree/scripts/package-codex-plugin.sh" + if output="$("$linked_worktree/scripts/package-codex-plugin.sh" --allow-dirty --metadata-source "$metadata_source" --output "$worktree_archive" 2>&1)"; then + pass "package script accepts a linked worktree checkout" + else + fail "package script accepts a linked worktree checkout" + printf '%s\n' "$output" | sed 's/^/ /' + fi + if [[ -f "$worktree_archive" ]]; then + pass "package script writes archive from a linked worktree" + else + fail "package script writes archive from a linked worktree" + fi +else + fail "create linked worktree fixture" +fi + extract_archive "$archive" "$extracted" archive_paths="$(list_archive "$archive" | normalize_archive_paths)" -- cgit