git 计算commit

转自:https://www.cnblogs.com/jwentest/p/8186712.html
#!/bin/bash f1="$1*" f2="$2*" echo "第一个版本:"$f1 echo "第二个版本:"$f2 git log | grep "commit [0-9a-zA-Z]\{40\}"|awk 'BEGIN{count=0;} {commit[count]=$2;count++;} END{for(i=0;i<NR;i++) print i,commit[i]}' | grep -E "$f1|$f2" > result LineNum=`awk 'END {print NR}' ./result` if [ $LineNum -lt 2 ];then echo "版本号输入错误,请检查输入的版本号" else num=`awk 'BEGIN{count=0;} {num[count]=$1;count++;} END{print sqrt((num[0]-num[1])*(num[0]-num[1]))+1}' ./result` echo "相差"$num"个版本" fi
posted @ 2019-08-24 22:19  little_ab  阅读(311)  评论(0编辑  收藏  举报