fix: git-sync для detached HEAD, shop-root требует .git

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
shop
2026-05-17 13:24:06 +03:00
parent b7c8d2ed80
commit da77b1f8da
5 changed files with 94 additions and 28 deletions
+21 -21
View File
@@ -1,31 +1,31 @@
#!/bin/bash
# Каталог репозитория (где package.json). Переопределение: SHOP_ROOT=/path
# Каталог репозитория (package.json + по возможности .git)
# Переопределение: SHOP_ROOT=/opt/shop/shop10
_resolve_shop_root() {
if [ -n "${SHOP_ROOT:-}" ] && [ -f "${SHOP_ROOT}/package.json" ]; then
return 0
fi
local here
here="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
if [ -f "${here}/package.json" ]; then
SHOP_ROOT="$here"
return 0
fi
if [ -f /opt/shop/shop10/package.json ]; then
SHOP_ROOT=/opt/shop/shop10
return 0
fi
if [ -f /opt/shop/package.json ]; then
SHOP_ROOT=/opt/shop
return 0
fi
local d
for d in \
"${SHOP_ROOT:-}" \
"$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" \
"/opt/shop/shop10" \
"/opt/shop"; do
[ -z "$d" ] && continue
[ -f "${d}/package.json" ] && [ -d "${d}/.git" ] && SHOP_ROOT="$d" && return 0
done
for d in \
"${SHOP_ROOT:-}" \
"$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" \
"/opt/shop/shop10" \
"/opt/shop"; do
[ -z "$d" ] && continue
[ -f "${d}/package.json" ] && SHOP_ROOT="$d" && return 0
done
return 1
}
if ! _resolve_shop_root; then
echo "Ошибка: не найден каталог Shop (нет package.json)."
echo "Перейдите в каталог клона и запустите:"
echo " bash scripts/server-update.sh"
echo "Или задайте: SHOP_ROOT=/opt/shop/shop10 bash scripts/server-update.sh"
echo " git clone https://git.evilfox.cc/test/shop10.git /opt/shop/shop10"
echo " SHOP_ROOT=/opt/shop/shop10 bash scripts/server-update.sh"
exit 1
fi