• 基于Gitlab统计代码行--统计所有仓库、所有提交人的代码总行数(新增加-删除)


    公司绩效考核要求,统计GITLAB仓库所有人提示有效代码行业

    脚本1: 统计所有仓库、所有提交人的代码总行数(新增加-删除) 脚本2: 统计所有仓库、所有提交人的代码提交汇总与删除汇总 脚本3: 统计指定仓库的所有提交人的代码提交 汇总与删除汇总

    注意:所有代码行数为0,统计结果中清除。 所有统计只统计master分支。

    安装: 把脚本中的仓库路径搜索修改为GitLab的存储目录。 统计结果存储在/home目录下面。

    [root@gitlab home]# cat code_statistics.sh
    #!/bin/bash
    master_dev='master'
    date_star='2018-11-01'
    date_end='2018-11-30'
    path1=`find /home/gitlab_data/ -name "*.git"`
    echo '' > /home/total.txt
    #echo $path1
    ##arr=($a)用于将字符串$a分割到数组$arr ${arr[0]} ${arr[1]} ... 分别存储分割后的数组第1 2 ... 项 ,${arr[@]}存储整个数组。变量$IFS存储着分隔符,这里我们将其设为逗号 "," OLD_IFS用于备份默认的分隔符,使用完后将之恢复默认。
    OLD_IFS="$IFS"
    IFS=" "
    arr=($path1)
    IFS="$OLD_IFS"
    for s in ${arr[@]}
    do

    #echo "$s"
    cd $s
    user1=`git log --pretty='%aN' | sort | uniq `
    OLD_IFS="$IFS1"
    IFS1=" "
    arr1=($user1)
    IFS="$OLD_IFS1"
    for s1 in ${arr1[@]}
    do

    #echo "$s1"

    # if [[ $s1 != *HEAD* ]]
    # then
    total=`git log $master_dev --since ==$date_star --until=$date_end --author=$s1 --pretty=tformat: --numstat | awk '{ loc += $1 -$2 } END { printf loc }'`
    #total_temp1=`git log $master_dev --since ==$date_star --until=$date_end --author='$s1' --pretty=tformat: --numstat | awk '{ printf $1}'`
    #echo $total_temp1
    # echo '' > /home/total.txt
    #if [ -n "$total" ];
    #then
    echo $s1 $total >> /home/total.txt
    #fi
    # fi
    #user1=`git log --pretty='%aN' | sort | uniq `

    done


    done


    cat /home/total.txt | awk '{a[$1]+=$2}END{for(i in a)print i,a[i]}' > /home/total_end.txt
    cat /home/total_end.txt |grep -v ' 0' > /home/total_all.txt

  • 相关阅读:
    E1696命令行错误: 无法打开元数据文件"platform.winmd"
    搭建集群hadoop
    搭建单节点hadoop
    搭建hadoop遇到的Q&A
    Q&A(Constantly Updating)
    基于Spark的SVM模型手写数字识别
    常见设计模式——装饰模式
    常见设计模式——策略模式
    常见设计模式——观察者模式
    常见设计模式——三种工厂模式(简单工厂、工厂方法、抽象工厂)
  • 原文地址:https://www.cnblogs.com/net2817/p/10040621.html
Copyright © 2020-2023  润新知