git branch -r --contains [ hash index]
远程仓库是否包含当前的提交
我写的注释什么的很少出现 日期的英文, 所以很好统计
#!/bin/bash
COUNTS=0
DATE=$(date | awk '{print $2}')
DIRS=$(ls)
CHECK_URL=git@10.0.128.128:sw/
INDEX=0
TODAY=$(date | awk '{printf "%s %s %s",$1,$2,$3}')
TODAY_COUNTS_ALL=0
for _DIRS in ${DIRS} ; do
if [[ -d ${_DIRS}/.git ]] ; then
_CNTS=$(cat ${_DIRS}/.git/config | grep -c "${CHECK_URL}")
INDEX=$((${INDEX}+1))
if [[ ${_CNTS} -eq 1 || ${_CNTS} -gt 1 ]] ; then
CNTS=$(cd ${_DIRS} && git log | grep -c "${DATE}" && cd ..)
TODAY_COUNTS=$(cd ${_DIRS} && git log | grep -c "${TODAY}" && cd ..)
printf "REPO: [ %-32s ] COMMITS %d times\n" ${_DIRS} ${CNTS}
COUNTS=$((${CNTS}+${COUNTS}))
TODAY_COUNTS_ALL=$((${TODAY_COUNTS}+${TODAY_COUNTS_ALL}))
fi
fi
done
printf "\n>>>> ALL COMMIT CNTS: %d \n" ${COUNTS}
printf ">>>> %s COMMIT CNTS: %d\n" "$(date)" ${TODAY_COUNTS_ALL}
优化一版本
#!/bin/bash
COUNTS=0
DATE=$(date | awk '{print $2}')
DIRS=$(ls)
CHECK_URL=git@10.0.128.128:sw/
INDEX=0
TODAY=$(date | awk '{printf "%s %s %s",$1,$2,$3}')
TODAY_COUNTS_ALL=0
AUTHOR=hongdayu
for _DIRS in ${DIRS} ; do
if [[ -d ${_DIRS}/.git ]] ; then
_CNTS=$(cat ${_DIRS}/.git/config | grep -c "${CHECK_URL}")
INDEX=$((${INDEX}+1))
AUT=$(cd ${_DIRS} && git log | grep -c "${AUTHOR}" && cd ..)
if ! [[ ${AUT} -eq 1 || ${AUT} -gt 1 ]] ; then
continue
fi
if [[ ${_CNTS} -eq 1 || ${_CNTS} -gt 1 ]] ; then
CNTS=$(cd ${_DIRS} && git log | grep -c "${DATE}" && cd ..)
TODAY_COUNTS=$(cd ${_DIRS} && git log | grep -c "${TODAY}" && cd ..)
printf "REPO: [ %-32s ] COMMITS %d times\n" ${_DIRS} ${CNTS}
COUNTS=$((${CNTS}+${COUNTS}))
TODAY_COUNTS_ALL=$((${TODAY_COUNTS}+${TODAY_COUNTS_ALL}))
fi
fi
done
printf "\n>>>> ALL COMMIT CNTS: %d \n" ${COUNTS}
printf ">>>> %s COMMIT CNTS: %d\n" "$(date)" ${TODAY_COUNTS_ALL}