Files
map-client-vue/test-release-extract.sh
2025-10-15 15:36:54 +08:00

61 lines
1.5 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 测试脚本:验证从 release.md 中提取版本信息
echo "🧪 测试版本信息提取逻辑"
echo "================================"
if [ ! -f release.md ]; then
echo "❌ 未找到 release.md"
exit 1
fi
# 提取最后一个版本号(去掉 ## 和空格)
VERSION=$(grep "^## v" release.md | tail -n 1 | sed 's/^## *//')
if [ -z "$VERSION" ]; then
echo "❌ release.md 中未找到版本号"
exit 1
fi
echo "📝 提取的版本号: $VERSION"
echo ""
# 提取该版本块的内容(从版本标题下一行到下一个版本或文件结尾)
TAG_MESSAGE=$(awk "
/^## $VERSION\$/ { flag=1; next }
/^## v[0-9]/ && flag { exit }
flag { print }
" release.md)
echo "📄 提取的内容长度: $(echo "$TAG_MESSAGE" | wc -l)"
echo ""
# 提取标题
RELEASE_TITLE=$(echo "$TAG_MESSAGE" | grep -m 1 "^###" | sed 's/^### *//' | sed 's/^[🎯✨🔧🐛📦]* *//')
if [ -z "$RELEASE_TITLE" ]; then
RELEASE_TITLE=$(echo "$TAG_MESSAGE" | grep -v "^$" | grep -v "^发布时间:" | head -n 1)
fi
if [ -z "$RELEASE_TITLE" ]; then
RELEASE_TITLE="Release $VERSION"
fi
echo "📌 提取的标题: $RELEASE_TITLE"
echo ""
echo "📄 完整内容预览前20行:"
echo "--------------------------------"
echo "$TAG_MESSAGE" | head -n 20
echo "--------------------------------"
echo ""
echo "✅ 测试完成"
echo ""
echo "🔍 提取结果总结:"
echo " 版本号: $VERSION"
echo " 标题: $RELEASE_TITLE"
echo " 内容行数: $(echo "$TAG_MESSAGE" | wc -l)"
echo " 完整标题: $VERSION - $RELEASE_TITLE"