输出效果
if [ -z $1 ] || [ -z $2 ];then
echo "统计从现在到某个日期的代码提交信息: update add del"
echo "使用方法: sh $1 仓库目录 4位年份-2位月份-2位日"
echo "使用示例: sh $1 ioc 2022-07-09"
fi
cd $1
git log --no-merges --shortstat --after="$2" --pretty=format:"" |grep -v '^$' > codes-count.txt
# 20 files changed, 1853 insertions(+), 1538 deletions(-)
add=`grep -P '[0-9]+ insertion' -o codes-count.txt |awk '{add +=$1}END{print add}'`
update=`grep -P '[0-9]+ files changed' -o codes-count.txt |awk '{update +=$1}END{print update}'`
del=`grep -P '[0-9]+ deletion' -o codes-count.txt |awk '{del +=$1}END{print del}'`
printf "%-12s %-12s %-10s\n" "新增(add)" "修改(update)" "删除(del)"
printf "%-12s %-12s %-10s\n" $add $update $del