feat: 快速提交 - 周一 2025/09/22 11:54:13.80

This commit is contained in:
赵杰 Jie Zhao (雄狮汽车科技)
2025-09-22 11:54:14 +01:00
parent 16bb98131e
commit a2b4fcdf36
10 changed files with 848 additions and 25 deletions

View File

@@ -38,15 +38,104 @@ if %errorlevel% neq 0 (
)
echo ✅ 文件已添加到暂存区
:: 生成提交信息
:: 检查markdown文件修改并生成智能提交信息
echo.
echo [3/4] 生成提交信息...
for /f "tokens=*" %%i in ('git log --oneline -1') do set last_commit=%%i
set /p commit_msg="请输入提交信息 (直接回车使用默认): "
if "%commit_msg%"=="" (
echo [3/4] 分析markdown文件并生成提交信息...
:: 检查是否有markdown文件修改
set md_files=
for /f "tokens=*" %%f in ('git diff --name-only --cached 2^>nul ^| findstr /i "\.md$"') do (
set md_files=!md_files! %%f
)
for /f "tokens=*" %%f in ('git diff --name-only 2^>nul ^| findstr /i "\.md$"') do (
set md_files=!md_files! %%f
)
set commit_msg=
if not "%md_files%"=="" (
echo 📝 检测到markdown文件修改:
echo %md_files%
echo.
:: 提取markdown文件的主要内容
set commit_title=
set commit_type=docs
:: 检查是否有修复相关内容
for %%f in (%md_files%) do (
if exist "%%f" (
for /f "tokens=*" %%l in ('type "%%f" ^| findstr /i "修复\|解决\|问题\|错误"') do (
set commit_type=fix
set commit_title=修复问题
goto :found_fix
)
)
)
:: 检查是否有新功能相关内容
for %%f in (%md_files%) do (
if exist "%%f" (
for /f "tokens=*" %%l in ('type "%%f" ^| findstr /i "功能\|新增\|添加\|实现"') do (
set commit_type=feat
set commit_title=新增功能
goto :found_feature
)
)
)
:: 检查是否有优化相关内容
for %%f in (%md_files%) do (
if exist "%%f" (
for /f "tokens=*" %%l in ('type "%%f" ^| findstr /i "优化\|性能\|改进\|提升"') do (
set commit_type=perf
set commit_title=性能优化
goto :found_optimization
)
)
)
:: 提取文件标题
for %%f in (%md_files%) do (
if exist "%%f" (
for /f "tokens=*" %%l in ('type "%%f" ^| findstr /n "^#" ^| head -1') do (
set line=%%l
set line=!line:*:=!
set line=!line:# =!
set line=!line:## =!
if "!line!" neq "" (
set commit_title=!line!
goto :found_title
)
)
)
)
:found_fix
:found_feature
:found_optimization
:found_title
if "%commit_title%"=="" (
set commit_title=更新文档记录
)
:: 生成提交信息
set commit_msg=%commit_type%: %commit_title%
echo 📋 生成的提交信息: %commit_msg%
echo.
) else (
echo 没有检测到markdown文件修改
set commit_msg=feat: 自动提交 - %date% %time%
)
:: 询问是否使用生成的提交信息
set /p confirm="是否使用此提交信息? (y/n/e编辑): "
if /i "%confirm%"=="e" (
set /p commit_msg="请输入自定义提交信息: "
) else if /i "%confirm%" neq "y" (
set /p commit_msg="请输入提交信息: "
)
:: 提交更改
echo 提交信息: %commit_msg%
git commit -m "%commit_msg%"