查询Gerrit指定状态的patch set,并保存到文件。采用分段查看首先查看最近500条的,再查看最近500-1000条的。以Json文件格式保存。后续处理做成Excel可以用Python等。
查询命令文档见https://review.openstack.org/Documentation/cmd-query.html
#!/bin/bash
#This is a script for get the history of the gerrit pathes
#USAGE: getpats project status time
#time meas after/since this time ,for exzampl 2017-01-01.every query will fetch 500 entries
if [ $# -lt 4 ];then
echo "wrong usage,USAGE: getpats.sh project status time,or see the script for more details "
exit 1
fi
segment=0
project=$1
status=$2
time=$3
savedfile=${project}${time}".re"
command=`ssh -p 29418 gerrit.louis.com gerrit query --format=JSON --start $segment status:$status after:$time projects:$project`
#每一次查询如果属于刚好满足查询条件的最后