feat: xavis ai_platform 기능 이전 및 ncue 환경 전환
xavis 소스·DB 스키마·활용사례/F-Scan/프롬프트 라이브러리 등 기능 반영. @xavis.co.kr → @ncue.net, 관리자 토큰 ncue-admin, 런타임 data/ Git 추적 제외. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
49
scripts/safe-git-pull.sh
Executable file
49
scripts/safe-git-pull.sh
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
# 배포 서버에서 런타임 data 파일의 **로컬 수정** 때문에
|
||||
# "Your local changes to the following files would be overwritten by merge" 가 나와
|
||||
# git pull 이 막힐 때 사용합니다.
|
||||
# 동작: 지정 경로를 백업 → 인덱스/작업트리를 리셃해 pull을 허용 → 백업을 다시 복사합니다.
|
||||
set -euo pipefail
|
||||
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
# pull 전에 Git이 덮어쓰기를 거부하는 런타임 전용 경로(필요 시 추가)
|
||||
PULL_SAFE_PATHS=(
|
||||
"data/ai-success-stories.json"
|
||||
)
|
||||
|
||||
STAMP="$(date +%Y%m%d%H%M%S)"
|
||||
BAK_DIR="${REPO_ROOT}/.tmp-safe-pull-backup-${STAMP}"
|
||||
mkdir -p "$BAK_DIR"
|
||||
|
||||
backed=()
|
||||
for relpath in "${PULL_SAFE_PATHS[@]}"; do
|
||||
if [[ -f "$relpath" ]]; then
|
||||
dest="${BAK_DIR}/$(echo "$relpath" | tr / _)"
|
||||
cp -a "$relpath" "$dest"
|
||||
backed+=("$relpath|$dest")
|
||||
fi
|
||||
done
|
||||
|
||||
# 추적 중이면 머지/체크아웃이 막힘 — 먼저 백업했으므로 작업트리·스테이징만 맞춤
|
||||
for relpath in "${PULL_SAFE_PATHS[@]}"; do
|
||||
if git ls-files --error-unmatch -- "$relpath" >/dev/null 2>&1; then
|
||||
if ! git restore --worktree --staged -- "$relpath" 2>/dev/null; then
|
||||
git reset -q HEAD -- "$relpath" 2>/dev/null || true
|
||||
git checkout -- "$relpath" 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
git pull "$@"
|
||||
|
||||
for ent in "${backed[@]}"; do
|
||||
relpath="${ent%%|*}"
|
||||
src="${ent#*|}"
|
||||
if [[ -f "$src" ]]; then
|
||||
cp -a "$src" "$relpath"
|
||||
fi
|
||||
done
|
||||
|
||||
rm -rf "$BAK_DIR"
|
||||
echo "safe-git-pull: 완료. 런타임 파일은 백업에서 복원되었습니다."
|
||||
Reference in New Issue
Block a user