-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.sh
More file actions
31 lines (23 loc) · 725 Bytes
/
Copy pathcheck.sh
File metadata and controls
31 lines (23 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash
set -euo pipefail
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$REPO_DIR"
TARGET_BRANCH="${1:-feat/astro-content-model-i18n-scaffold}"
echo "[check.sh] repo: $REPO_DIR"
echo "[check.sh] target branch: $TARGET_BRANCH"
echo "[check.sh] fetch origin..."
git fetch origin
if git show-ref --verify --quiet "refs/heads/$TARGET_BRANCH"; then
git checkout "$TARGET_BRANCH"
else
git checkout -b "$TARGET_BRANCH" "origin/$TARGET_BRANCH"
fi
echo "[check.sh] pull latest..."
git pull --rebase origin "$TARGET_BRANCH"
# 防止 Windows CRLF 导致 /usr/bin/env: 'bash\r' 报错
if [ -f run.sh ]; then
sed -i 's/\r$//' run.sh
chmod +x run.sh
fi
echo "[check.sh] run local preview..."
exec bash ./run.sh