-
Notifications
You must be signed in to change notification settings - Fork 380
Expand file tree
/
Copy pathupdate.sh
More file actions
42 lines (35 loc) · 1.1 KB
/
update.sh
File metadata and controls
42 lines (35 loc) · 1.1 KB
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
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# This script is used to manually fetch blueprints from remote
LOG_PATH="update.log"
REMOTE_URI="git@github.com:DSPBluePrints/FactoryBluePrints.git"
cd "$(dirname "$0")"
# debug info
ls > $LOG_PATH
echo "----" >> $LOG_PATH
# test dir
if [ ! -d "../../Blueprint" ]; then
echo "$(date '+%x %X') Warning: Abnormal installation path" >> "$LOG_PATH"
echo "警告:您似乎安装到了错误的路径,这可能导致文件权限异常"
fi
# test git
# git should already be installed as a package
if git --version &> /dev/null; then
echo "$(date '+%x %X') Infomation: GIT_PATH=$(command -v git)"
else
echo "错误:无法找到git"
echo "$(date '+%x %X') Error: git not found" >> "$LOG_PATH"
exit 1
fi
# find .git
if [ ! -d ".git" ]; then
echo "警告:无法找到.git"
echo "$(date '+%x %X') Warning: .git not found" >> "$LOG_PATH"
git init
git remote add origin $REMOTE_URI
fi
# force-reset
git remote set-url origin $REMOTE_URI
git fetch --all
git reset --hard origin/main
echo "$(date '+%x %X') Information : git reset --hard" >> "$LOG_PATH"
# git clean -fd