fix(task-management): support git worktrees in router root detection (#301)

find_project_root used [ -d "$dir/.git" ], which fails in a git worktree where .git is a file containing a gitdir: pointer rather than a directory. Switches to -e (a strict superset, so the normal-repo case is unaffected; submodules are fixed for free).

Also changes return 1 to return 0 in the fallback branch: PROJECT_ROOT="$(find_project_root)" takes the command substitution's exit status, so under set -e the script aborted after the fallback value had already been computed, producing silent no-output.

Mainly affects non-Node projects consuming OAC from a worktree; this repo's root package.json masks the bug.
This commit is contained in:
discord9 2026-07-15 07:53:00 +08:00 committed by GitHub
parent cde3efe56f
commit 0879d0493b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -72,14 +72,14 @@ find_project_root() {
local dir local dir
dir="$(pwd)" dir="$(pwd)"
while [ "$dir" != "/" ]; do while [ "$dir" != "/" ]; do
if [ -d "$dir/.git" ] || [ -f "$dir/package.json" ]; then if [ -e "$dir/.git" ] || [ -f "$dir/package.json" ]; then
echo "$dir" echo "$dir"
return 0 return 0
fi fi
dir="$(dirname "$dir")" dir="$(dirname "$dir")"
done done
pwd pwd
return 1 return 0
} }
# Handle help # Handle help