zoukankan      html  css  js  c++  java
  • 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

    统计结果:

  • 相关阅读:
    初识react hooks
    react初识生命周期
    在调用setState之后发生了什么
    课后作业四
    课后作业2
    课后作业1
    自我介绍
    电脑软件推荐
    数据结构
    数组(一维数组)
  • 原文地址:https://www.cnblogs.com/JamKong/p/8231022.html
Copyright © 2011-2022 走看看