• git 统计代码量 shell脚本


    #!/bin/bash
    # 统计代码量
    # 使用方法: sh gitstat.sh "2017-11-01" "2017-11-30" "JamKong" ~/workspace/IDEA/项目名/
    # 开始时间
    startTime=`date -j -f "%Y-%m-%d" $1 +%s`
    # 结束时间
    endTime=`date -j -f "%Y-%m-%d" $2 +%s`
    # 提交代码作者
    author=$3
    # 项目绝对路径
    path=$4||'.'
    
    internalDay=$((($endTime-$startTime)/60/60/24 + 1))
    echo "统计总天数:"$internalDay ""
    
    cd $path
    
    preTime=$startTime
    nextTime=$startTime
    echo "提交者 $3: " 
    for (( i=1;i<=$internalDay;i++));do
        temp=$nextTime
        nextTime=`date -r $(( $nextTime + 86400)) +%s`
        preTime=$temp
        echo `date -r $preTime +"%Y%m%d"` - `date -r $nextTime +"%Y%m%d" ` ": c"
        git log --since=$preTime --until=$nextTime  --author=$3 --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 + $2 } END { printf "added lines: %-15s   |   removed lines: %-15s   |   total lines: %-15s
    ", add, subs, loc }'    
    done
    echo 
    echo
    echo "汇总:c"
    git log --since=$1  --until=$2 --author=$3 --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 + $2 } END { printf "added lines: %-15s   |   removed lines: %-15s   |   total lines: %-15s
    ", add, subs, loc }'    
    echo

    统计结果:

  • 相关阅读:
    vivado工程移植
    Search Everything 多项查找
    RTL_代码覆盖率
    在ARTIX-7上实现摄像头视频通路
    转:自动生成testbench
    转:winedt中显示中文
    Zynq和microblaze的区别
    转:找不到include xgpio.h;Unresolved include xgpio.h
    DHTMLX 常用技术
    Ubuntu中安装 mercurial – TortoiseHG
  • 原文地址:https://www.cnblogs.com/JamKong/p/8231022.html
Copyright © 2020-2023  润新知