2017-04-25 63 views
5

我试图发送一个包含开发人员每天在git存储库中完成的提交数的报告。如何在特定分支的Git存储库中获取开发人员提交的日期数

#read all the inputs 
read -p "Enter the Branch Name:" branchname 
read -p "Enter the from date:" frmdate 
read -p "Enter the To date:" todate 

#execute the command to get the commit history 
git log origin/$branchname --name-status --pretty=format:"%cn committed %h on %cd full" --after="$frmdate 00:00" --before="$todate 23:59" --decorate | git shortlog -s -n > history.txt 

此脚本可以帮助我创建一个文件,其中包含更改的文件和给定日期的用户。但是我需要个人开发者提交的数据。

我试过git shortlog -s -n,它给出了开发人员在所有分支机构中的总体承诺数。

需要创建一个报告,以获得在日常工作中提交每个开发人员的数量

+0

一定要注脚添加到您的报告中说:你有用的东西,请参阅http://dilbert.com/strip/1995-11-13** – Caleb

回答

3

嗯....我会做的是:

  • 获取的开发谁制作的列表该分支自昨天起。
  • 管,列出成,而这样就可以得到什么每一个

这将是这样的:

the_date=$(date +%F) 
git log --pretty="%ae" --since=yesterday the-branch | sort | uniq | while read author; do 
    git log --author=$author --since-yesterday the-branch > "$the_date"_"$author".txt 
done 

如果您需要更多的信息(如那名文件改变等等,只需在while循环内添加更多选项到日志通话中即可。

1

我认为下面的代码块应该适合你。

#read all the inputs 
read -p "Enter the Branch Name:" branchname 
read -p "Enter the from date:" frmdate 
read -p "Enter the To date:" todate 

#execute the command to get the commit history 
git log origin/$branchname --pretty=format:"%cn %ci" \ 
--after="$frmdate 00:00" --before="$todate 23:59"| 
gawk '{arr[$2][$1]++} 
    END{ 
    PROCINFO["sorted_in"] = "@ind_str_desc"; 
    for (date_arr in arr){ 
     printf("%s:\n", date_arr); 
     PROCINFO["sorted_in"] = "@val_num_desc"; 
     for (author in arr[date_arr]){ 
      printf("\t%s: %s\n", author, arr[date_arr][author]); 
     } 
    } 
    }' 
echo "==================================" 
git shortlog -s -n 

的逻辑是:

  1. 获取提交行2列:提交作者和提交日期;
  2. 在gawk的帮助下制作一个类似SQL的group byorder by查询。

*请注意,这不适用于作者名称与空白在其中。

3

在一行试试这个(作为一个命令):

git log --pretty="%cd %aE" --date='format:%Y-%m-%d' BRANCH | 
sort -r | 
uniq -c | 
grep AUTHOR_YOU_ARE_INTERESTED_IN 

输出示例:

1 2017-05-10 [email protected] 
    2 2017-04-13 [email protected] 
    1 2017-03-30 [email protected] 
    1 2017-03-03 [email protected] 
    2 2017-01-24 [email protected] 
    1 2016-12-14 [email protected] 
    1 2016-11-23 [email protected] 
    1 2016-11-21 [email protected] 
    1 2016-11-18 [email protected] 
    3 2016-11-16 [email protected] 

报告失踪日期暗示该人是该分支没有提交对失踪日期。

最左边的数字(1,2,1,1等)是作者在当天提交的提交数量。

1

git shortlog可以在一系列提交中产生每个开发者的提交计数报告。由于开始和结束日期,你可以找到SHA1为范围端点使用git rev-list使用,例如:如果你觉得每天提交计数告诉**:

start=$(git rev-list -n1 master --before START_DATE) 
end=$(git rev-list -n1 master --before END_DATE) 
git shortlog -sn $start..$end 
相关问题