From 5a653ecc7c13bc3525de4d1b2abd33d5e91b904a Mon Sep 17 00:00:00 2001 From: bWFuanVzYWth Date: Tue, 25 Apr 2023 23:19:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=9B=B4=E6=96=B0=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- update.bat | 68 ++++++++++++++++++++++++++++++++++++++++++++ 双击更新蓝图仓库.bat | 45 ----------------------------- 2 files changed, 68 insertions(+), 45 deletions(-) create mode 100644 update.bat delete mode 100644 双击更新蓝图仓库.bat diff --git a/update.bat b/update.bat new file mode 100644 index 0000000..aadae82 --- /dev/null +++ b/update.bat @@ -0,0 +1,68 @@ +chcp 65001 +@echo off + +::debug info +set LOG_PATH=.\update.log +dir>%LOG_PATH% +echo ---->>%LOG_PATH% + +::find git.exe +if exist ".\MinGit\cmd\git.exe" ( +set GIT_PATH=.\MinGit\cmd\git.exe +echo %date% %time% Infomation: GIT_PATH=.\MinGit\cmd\git.exe>>%LOG_PATH% +) else ( +set GIT_PATH=git +echo %date% %time% Infomation: GIT_PATH=git>>%LOG_PATH% +) + +::test git.exe +%GIT_PATH% -v +if %errorlevel% NEQ 0 ( +echo 错误:无法找到git.exe ^| Error: git.exe no found +echo %date% %time% Error: git.exe no found>>%LOG_PATH% +goto end_with_error +) + +::find .git/ +if not exist ".git" ( +echo 错误:无法找到git.exe ^| Error: git.exe no found +echo %date% %time% Error: git.exe no found>>%LOG_PATH% +goto end_with_error +) + +::test .git/ +git rev-parse --is-inside-work-tree +if %errorlevel% NEQ 0 ( +echo 错误:.git/已损坏 ^| Error: .git/ is broken +echo %date% %time% Error: .git/ is broken>>%LOG_PATH% +goto end_with_error +) + +::init +if not exist ".\.gitignore" ( +%GIT_PATH% reset --hard +echo %date% %time% Infomation: %GIT_PATH% reset --hard>>%LOG_PATH% +) + +::update +set GIT_SSL_NO_VERIFY=true +%GIT_PATH% pull origin main +if %errorlevel% NEQ 0 ( +echo 错误:更新失败,这通常是网络问题。请重试,或者开加速器再更新。详见"README.md" +echo %date% %time% Error: %GIT_PATH% pull origin main>>%LOG_PATH% +goto end_with_error +) else ( +echo %date% %time% Infomation: %GIT_PATH% pull origin main>>%LOG_PATH% +) + +:end +echo 更新完成,现在可以直接关闭此窗口 +echo %date% %time% Infomation: Exit>>%LOG_PATH% +pause +exit + +:end_with_error +echo 更新因为出现错误而终止。如果存疑可以加qq群反馈:162065696 +echo %date% %time% Infomation: Exit>>%LOG_PATH% +pause +exit \ No newline at end of file diff --git a/双击更新蓝图仓库.bat b/双击更新蓝图仓库.bat deleted file mode 100644 index e74ac20..0000000 --- a/双击更新蓝图仓库.bat +++ /dev/null @@ -1,45 +0,0 @@ -chcp 65001 -@echo off - -set LOG_PATH=.\update.log - -dir>%LOG_PATH% - -echo ---->>%LOG_PATH% - -echo INF: %date% %time% Start>>%LOG_PATH% - -::find git -if exist ".\MinGit\cmd\git.exe" ( -set GIT_PATH=.\MinGit\cmd\git.exe -echo INF: %date% %time% GIT_PATH=.\MinGit\cmd\git.exe>>%LOG_PATH% -) else if exist "C:\Program Files\Git" ( -set GIT_PATH=git -echo INF: %date% %time% GIT_PATH=git>>%LOG_PATH% -) else ( -echo 警告:无法找到Git或MinGit。如果更新能正常进行请忽略 ^| Warning: Could not find Git or MinGit. Please ignore if the update works normally -echo WAR: %date% %time% Git/MinGit no found>>%LOG_PATH% -set GIT_PATH=git -) - -::init -if not exist ".\.gitignore" ( -%GIT_PATH% reset --hard -) - -::update -echo INF: %date% %time% git pull start>>%LOG_PATH% -git config core.longpaths true -set GIT_SSL_NO_VERIFY=true -%GIT_PATH% pull origin main -if %errorlevel% NEQ 0 ( -echo ERR: %date% %time% git pull error>>%LOG_PATH% -echo 错误:更新失败,这通常是网络问题。请重试,或者开加速器再更新。详见"README.md" -) else ( -echo INF: %date% %time% git pull successed>>%LOG_PATH% -) - -::end -echo INF: %date% %time% Exit>>%LOG_PATH% -pause -exit