代码拉取完成,页面将自动刷新
#!/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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。