加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CHANGELOG.sh 1.72 KB
一键复制 编辑 原始数据 按行查看 历史
郭静 提交于 2021-12-22 18:01 . init
#!/bin/bash
## Author LinkinStar
# solve the space by IFS
IFS=`echo -en "\n\b"`
echo -en $IFS
if [ -f "CHANGELOG.md" ];then
rm -f CHANGELOG.md
touch CHANGELOG.md
else
touch CHANGELOG.md
fi
function printFeat(){
for i in ${feat[@]}
do
echo "- "$i >> CHANGELOG.md
done
echo >> CHANGELOG.md
}
function printFix(){
for i in ${fix[@]}
do
echo "- "$i >> CHANGELOG.md
done
echo >> CHANGELOG.md
}
function printOther(){
for i in ${other[@]}
do
echo "- "$i >> CHANGELOG.md
done
echo >> CHANGELOG.md
}
function checkLog(){
if [[ $1 == "feat"* ]]
then
feat[featIndex]=$1
let featIndex++
elif [[ $1 == "fix"* ]]
then
fix[fixIndex]=$1
let fixIndex++
else
other[otherIndex]=$1
let otherIndex++
fi
}
function printLog(){
if [[ $featIndex -ne 0 ]]; then
echo "### Features" >> CHANGELOG.md
printFeat
fi
if [[ $fixIndex -ne 0 ]]; then
echo "### Bug Fixes" >> CHANGELOG.md
printFix
fi
if [[ $otherIndex -ne 0 ]]; then
echo "### Other Changes" >> CHANGELOG.md
printOther
fi
feat=()
featIndex=0
fix=()
fixIndex=0
other=()
otherIndex=0
}
curDate=""
function checkDate()
{
if [[ $curDate = $1 ]]; then
return
fi
curDate=$1
printLog
echo >> CHANGELOG.md
echo "## "$curDate >> CHANGELOG.md
}
commitMessageList=`git log --date=format:'%Y-%m-%d' --pretty=format:'%cd%n%s'`
index=0
for i in ${commitMessageList[@]}
do
if [[ $index%2 -eq 0 ]]
then
checkDate $i
else
#echo "- "$i >> CHANGELOG.md
checkLog $i
fi
let index++
done
printLog
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化