簡體   English   中英

如何計算 Git 存儲庫中特定作者更改的總行數?

[英]How to count total lines changed by a specific author in a Git repository?

是否有我可以調用的命令來計算 Git 存儲庫中特定作者更改的行數? 我知道必須有辦法計算提交的數量,因為 Github 為他們的影響圖做了這個。

這給出了一些關於作者的統計數據,根據需要修改。

使用 Gawk:

git log --author="_Your_Name_Here_" --pretty=tformat: --numstat \
| gawk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s removed lines: %s total lines: %s\n", add, subs, loc }' -

在 Mac OSX 上使用 awk:

git log --author="_Your_Name_Here_" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -

編輯 (2017)

github 上有一個新包,它看起來很漂亮,並使用 bash 作為依賴項(在 linux 上測試)。 它更適合直接使用而不是腳本。

它是git-quick-stats (github 鏈接)

git-quick-stats復制到一個文件夾並將該文件夾添加到路徑。

mkdir ~/source
cd ~/source
git clone git@github.com:arzzen/git-quick-stats.git
mkdir ~/bin
ln -s ~/source/git-quick-stats/git-quick-stats ~/bin/git-quick-stats
chmod +x ~/bin/git-quick-stats
export PATH=${PATH}:~/bin

用法:

git-quick-stats

在此處輸入圖片說明

以下命令的輸出應該很容易發送到腳本以將總數相加:

git log --author="<authorname>" --oneline --shortstat

這提供了當前 HEAD 上所有提交的統計信息。 如果要在其他分支中添加統計信息,則必須將它們作為參數提供給git log

為了傳遞給腳本,甚至可以使用空日志格式刪除“單行”格式,正如 Jakub Narębski 所評論的那樣,-- --numstat是另一種選擇。 它生成每個文件而不是每個行的統計信息,但更容易解析。

git log --author="<authorname>" --pretty=tformat: --numstat

如果有人想查看他們代碼庫中每個用戶的統計數據,我的幾個同事最近想出了這個可怕的單行:

git log --shortstat --pretty="%cE" | sed 's/\(.*\)@.*/\1/' | grep -v "^$" | awk 'BEGIN { line=""; } !/^ / { if (line=="" || !match(line, $0)) {line = $0 "," line }} /^ / { print line " # " $0; line=""}' | sort | sed -E 's/# //;s/ files? changed,//;s/([0-9]+) ([0-9]+ deletion)/\1 0 insertions\(+\), \2/;s/\(\+\)$/\(\+\), 0 deletions\(-\)/;s/insertions?\(\+\), //;s/ deletions?\(-\)//' | awk 'BEGIN {name=""; files=0; insertions=0; deletions=0;} {if ($1 != name && name != "") { print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net"; files=0; insertions=0; deletions=0; name=$1; } name=$1; files+=$2; insertions+=$3; deletions+=$4} END {print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net";}'

(需要幾分鍾來處理我們的 repo,其中有大約 10-15k 次提交。)

git-成名

https://github.com/oleander/git-fame-rb

這是一個很好的工具,可以一次獲取所有作者的計數,包括提交和修改的文件計數:

sudo apt-get install ruby-dev
sudo gem install git_fame
cd /path/to/gitdir && git fame

https://github.com/casperdcl/git-fame 上也有 Python 版本(@fracz 提到):

sudo apt-get install python-pip python-dev build-essential 
pip install --user git-fame
cd /path/to/gitdir && git fame

示例輸出:

Total number of files: 2,053
Total number of lines: 63,132
Total number of commits: 4,330

+------------------------+--------+---------+-------+--------------------+
| name                   | loc    | commits | files | percent            |
+------------------------+--------+---------+-------+--------------------+
| Johan Sørensen         | 22,272 | 1,814   | 414   | 35.3 / 41.9 / 20.2 |
| Marius Mathiesen       | 10,387 | 502     | 229   | 16.5 / 11.6 / 11.2 |
| Jesper Josefsson       | 9,689  | 519     | 191   | 15.3 / 12.0 / 9.3  |
| Ole Martin Kristiansen | 6,632  | 24      | 60    | 10.5 / 0.6 / 2.9   |
| Linus Oleander         | 5,769  | 705     | 277   | 9.1 / 16.3 / 13.5  |
| Fabio Akita            | 2,122  | 24      | 60    | 3.4 / 0.6 / 2.9    |
| August Lilleaas        | 1,572  | 123     | 63    | 2.5 / 2.8 / 3.1    |
| David A. Cuadrado      | 731    | 111     | 35    | 1.2 / 2.6 / 1.7    |
| Jonas Ängeslevä        | 705    | 148     | 51    | 1.1 / 3.4 / 2.5    |
| Diego Algorta          | 650    | 6       | 5     | 1.0 / 0.1 / 0.2    |
| Arash Rouhani          | 629    | 95      | 31    | 1.0 / 2.2 / 1.5    |
| Sofia Larsson          | 595    | 70      | 77    | 0.9 / 1.6 / 3.8    |
| Tor Arne Vestbø        | 527    | 51      | 97    | 0.8 / 1.2 / 4.7    |
| spontus                | 339    | 18      | 42    | 0.5 / 0.4 / 2.0    |
| Pontus                 | 225    | 49      | 34    | 0.4 / 1.1 / 1.7    |
+------------------------+--------+---------+-------+--------------------+

但請注意:正如 Jared 在評論中所提到的,在非常大的存儲庫上執行此操作需要數小時。 不確定這是否可以改進,因為它必須處理如此多的 Git 數據。

我發現以下內容對於查看誰擁有當前代碼庫中最多的行很有用:

git ls-files -z | xargs -0n1 git blame -w | ruby -n -e '$_ =~ /^.*\((.*?)\s[\d]{4}/; puts $1.strip' | sort -f | uniq -c | sort -n

其他答案主要集中在提交中更改的行上,但如果提交不存在並被覆蓋,則它們可能只是被攪動了。 上面的咒語還可以讓您按行排序所有提交者,而不是一次一個。 您可以向 git blame (-C -M) 添加一些選項以獲得更好的數字,這些數字將文件移動和文件之間的行移動考慮在內,但如果您這樣做,該命令可能會運行更長的時間。

此外,如果您正在尋找所有提交者的所有提交中更改的行,以下小腳本會有所幫助:

http://git-wt-commit.rubyforge.org/#git-rank-contributors

要計算給定作者(或所有作者)在給定分支上的提交次數,您可以使用git-shortlog 見特別是其--numbered--summary選項,例如,當在Git倉庫中運行:

$ git shortlog v1.6.4 --numbered --summary
  6904  Junio C Hamano
  1320  Shawn O. Pearce
  1065  Linus Torvalds
    692  Johannes Schindelin
    443  Eric Wong

看了AlexGerty3000的回答后,我試圖縮短單行:

基本上,使用 git log numstat 而不是跟蹤更改的文件數。

Mac OSX 上的 Git 2.1.0 版:

git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done

例子:

Jared Burrows   added lines: 6826, removed lines: 2825, total lines: 4001

AaronM使用 shell one-liner 的答案很好,但實際上,還有另一個錯誤,如果用戶名和日期之間有不同數量的空格,空格會破壞用戶名。 損壞的用戶名將為用戶計數提供多行,您必須自己總結它們。

這個小改動為我解決了這個問題:

git ls-files -z | xargs -0n1 git blame -w --show-email | perl -n -e '/^.*?\((.*?)\s+[\d]{4}/; print $1,"\n"' | sort -f | uniq -c | sort -n

請注意 \\s 之后的 +,它將消耗從名稱到日期的所有空格。

實際上添加這個答案是為了我自己的記憶和幫助其他人,因為這至少是我第二次用谷歌搜索這個主題:)

  • 編輯 2019-01-23添加--show-emailgit blame -w來聚合電子郵件,因為有些人在不同的計算機上使用不同的Name格式,有時兩個同名的人在同一個 git 中工作。

這是一個簡短的單行代碼,可為所有作者生成統計數據。 它比https://stackoverflow.com/a/20414465/1102119 上的Dan 解決方案快得多(我的時間復雜度為 O(N) 而不是 O(NM),其中 N 是提交數,M 是作者數)。

git log --no-merges --pretty=format:%an --numstat | awk '/./ && !author { author = $0; next } author { ins[author] += $1; del[author] += $2 } /^$/ { author = ""; next } END { for (a in ins) { printf "%10d %10d %10d %s\n", ins[a] - del[a], ins[a], del[a], a } }' | sort -rn

@mmrobins @AaronM @ErikZ @JamesMishra 提供的變體都有一個共同的問題:他們要求 git 生成不供腳本使用的混合信息,包括同一行上存儲庫的行內容,然后將混亂與正則表達式匹配.

當某些行不是有效的 UTF-8 文本時,以及當某些行碰巧與正則表達式匹配時(這發生在這里),這是一個問題。

這是一條沒有這些問題的修改后的線路。 它要求 git 在單獨的行上干凈地輸出數據,這使得我們可以輕松地穩健地過濾我們想要的內容:

git ls-files -z | xargs -0n1 git blame -w --line-porcelain | grep -a "^author " | sort -f | uniq -c | sort -n

您可以對其他字符串進行 grep,例如作者郵件、提交者等。

也許首先做export LC_ALL=C (假設bash )以強制字節級處理(這也恰好從基於 UTF-8 的語言環境極大地加快了 grep 的速度)。

中間使用 ruby​​ 給出了一個解決方案,默認情況下 perl 更可用一點,這里是作者對當前行使用 perl 的替代方法。

git ls-files -z | xargs -0n1 git blame -w | perl -n -e '/^.*\((.*?)\s*[\d]{4}/; print $1,"\n"' | sort -f | uniq -c | sort -n

你可以使用 whodid ( https://www.npmjs.com/package/whodid )

$ npm install whodid -g
$ cd your-project-dir

$ whodid author --include-merge=false --path=./ --valid-threshold=1000 --since=1.week

或者只是輸入

$ whodid

然后你可以看到這樣的結果

Contribution state
=====================================================
 score  | author
-----------------------------------------------------
 3059   | someguy <someguy@tensorflow.org>
 585    | somelady <somelady@tensorflow.org>
 212    | niceguy <nice@google.com>
 173    | coolguy <coolgay@google.com>
=====================================================

除了Charles Bailey 的回答之外,您可能還想在命令中添加-C參數。 否則,即使文件內容沒有被修改,文件重命名也會計為大量的添加和刪除(與文件的行數一樣多)。

為了說明這一點,當使用git log --oneline --shortstat命令時,這是一個提交,其中有許多文件從我的一個項目中移動:

9052459 Reorganized project structure
 43 files changed, 1049 insertions(+), 1000 deletions(-)

這里使用git log --oneline --shortstat -C命令進行相同的提交,該命令檢測文件副本和重命名:

9052459 Reorganized project structure
 27 files changed, 134 insertions(+), 85 deletions(-)

在我看來,后者更真實地說明了一個人對項目的影響有多大,因為重命名文件比從頭開始編寫文件要小得多。

這是一個快速的 ruby​​ 腳本,可以將每個用戶對給定日志查詢的影響集中起來。

例如,對於rubinius

Brian Ford: 4410668
Evan Phoenix: 1906343
Ryan Davis: 855674
Shane Becker: 242904
Alexander Kellett: 167600
Eric Hodel: 132986
Dirkjan Bussink: 113756
...

劇本:

#!/usr/bin/env ruby

impact = Hash.new(0)

IO.popen("git log --pretty=format:\"%an\" --shortstat #{ARGV.join(' ')}") do |f|
  prev_line = ''
  while line = f.gets
    changes = /(\d+) insertions.*(\d+) deletions/.match(line)

    if changes
      impact[prev_line] += changes[1].to_i + changes[2].to_i
    end

    prev_line = line # Names are on a line of their own, just before the stats
  end
end

impact.sort_by { |a,i| -i }.each do |author, impact|
  puts "#{author.strip}: #{impact}"
end

這是最好的方法,它還可以讓您清楚地了解所有用戶的提交總數

git shortlog -s -n

這是一個很棒的 repo,可以讓您的生活更輕松

git-quick-stats

在安裝了 brew 的 Mac 上

brew install git-quick-stats

跑步

git-quick-stats

只需輸入列出的數字並按回車鍵,即可從此列表中選擇您想要的選項。

 Generate:
    1) Contribution stats (by author)
    2) Contribution stats (by author) on a specific branch
    3) Git changelogs (last 10 days)
    4) Git changelogs by author
    5) My daily status
    6) Save git log output in JSON format

 List:
    7) Branch tree view (last 10)
    8) All branches (sorted by most recent commit)
    9) All contributors (sorted by name)
   10) Git commits per author
   11) Git commits per date
   12) Git commits per month
   13) Git commits per weekday
   14) Git commits per hour
   15) Git commits by author per hour

 Suggest:
   16) Code reviewers (based on git history)

我提供了對上面簡短答案的修改,但不足以滿足我的需求。 我需要能夠對提交的行和最終代碼中的行進行分類。 我還想按文件細分。 這段代碼不會遞歸,它只會返回單個目錄的結果,但如果有人想更進一步,這是一個好的開始。 復制並粘貼到文件中並使其可執行或使用 Perl 運行它。

#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;

my $dir = shift;

die "Please provide a directory name to check\n"
    unless $dir;

chdir $dir
    or die "Failed to enter the specified directory '$dir': $!\n";

if ( ! open(GIT_LS,'-|','git ls-files') ) {
    die "Failed to process 'git ls-files': $!\n";
}
my %stats;
while (my $file = <GIT_LS>) {
    chomp $file;
    if ( ! open(GIT_LOG,'-|',"git log --numstat $file") ) {
        die "Failed to process 'git log --numstat $file': $!\n";
    }
    my $author;
    while (my $log_line = <GIT_LOG>) {
        if ( $log_line =~ m{^Author:\s*([^<]*?)\s*<([^>]*)>} ) {
            $author = lc($1);
        }
        elsif ( $log_line =~ m{^(\d+)\s+(\d+)\s+(.*)} ) {
            my $added = $1;
            my $removed = $2;
            my $file = $3;
            $stats{total}{by_author}{$author}{added}        += $added;
            $stats{total}{by_author}{$author}{removed}      += $removed;
            $stats{total}{by_author}{total}{added}          += $added;
            $stats{total}{by_author}{total}{removed}        += $removed;

            $stats{total}{by_file}{$file}{$author}{added}   += $added;
            $stats{total}{by_file}{$file}{$author}{removed} += $removed;
            $stats{total}{by_file}{$file}{total}{added}     += $added;
            $stats{total}{by_file}{$file}{total}{removed}   += $removed;
        }
    }
    close GIT_LOG;

    if ( ! open(GIT_BLAME,'-|',"git blame -w $file") ) {
        die "Failed to process 'git blame -w $file': $!\n";
    }
    while (my $log_line = <GIT_BLAME>) {
        if ( $log_line =~ m{\((.*?)\s+\d{4}} ) {
            my $author = $1;
            $stats{final}{by_author}{$author}     ++;
            $stats{final}{by_file}{$file}{$author}++;

            $stats{final}{by_author}{total}       ++;
            $stats{final}{by_file}{$file}{total}  ++;
            $stats{final}{by_file}{$file}{total}  ++;
        }
    }
    close GIT_BLAME;
}
close GIT_LS;

print "Total lines committed by author by file\n";
printf "%25s %25s %8s %8s %9s\n",'file','author','added','removed','pct add';
foreach my $file (sort keys %{$stats{total}{by_file}}) {
    printf "%25s %4.0f%%\n",$file
            ,100*$stats{total}{by_file}{$file}{total}{added}/$stats{total}{by_author}{total}{added};
    foreach my $author (sort keys %{$stats{total}{by_file}{$file}}) {
        next if $author eq 'total';
        if ( $stats{total}{by_file}{$file}{total}{added} ) {
            printf "%25s %25s %8d %8d %8.0f%%\n",'', $author,@{$stats{total}{by_file}{$file}{$author}}{qw{added removed}}
            ,100*$stats{total}{by_file}{$file}{$author}{added}/$stats{total}{by_file}{$file}{total}{added};
        } else {
            printf "%25s %25s %8d %8d\n",'', $author,@{$stats{total}{by_file}{$file}{$author}}{qw{added removed}} ;
        }
    }
}
print "\n";

print "Total lines in the final project by author by file\n";
printf "%25s %25s %8s %9s %9s\n",'file','author','final','percent', '% of all';
foreach my $file (sort keys %{$stats{final}{by_file}}) {
    printf "%25s %4.0f%%\n",$file
            ,100*$stats{final}{by_file}{$file}{total}/$stats{final}{by_author}{total};
    foreach my $author (sort keys %{$stats{final}{by_file}{$file}}) {
        next if $author eq 'total';
        printf "%25s %25s %8d %8.0f%% %8.0f%%\n",'', $author,$stats{final}{by_file}{$file}{$author}
            ,100*$stats{final}{by_file}{$file}{$author}/$stats{final}{by_file}{$file}{total}
            ,100*$stats{final}{by_file}{$file}{$author}/$stats{final}{by_author}{total}
        ;
    }
}
print "\n";


print "Total lines committed by author\n";
printf "%25s %8s %8s %9s\n",'author','added','removed','pct add';
foreach my $author (sort keys %{$stats{total}{by_author}}) {
    next if $author eq 'total';
    printf "%25s %8d %8d %8.0f%%\n",$author,@{$stats{total}{by_author}{$author}}{qw{added removed}}
        ,100*$stats{total}{by_author}{$author}{added}/$stats{total}{by_author}{total}{added};
};
print "\n";


print "Total lines in the final project by author\n";
printf "%25s %8s %9s\n",'author','final','percent';
foreach my $author (sort keys %{$stats{final}{by_author}}) {
    printf "%25s %8d %8.0f%%\n",$author,$stats{final}{by_author}{$author}
        ,100*$stats{final}{by_author}{$author}/$stats{final}{by_author}{total};
}

該問題要求提供有關特定作者的信息,但許多答案是根據更改的代碼行返回作者排名列表的解決方案。

這就是我正在尋找的,但現有的解決方案並不完美。 為了可能通過 Google 找到這個問題的人的興趣,我對它們進行了一些改進,並將它們制作成一個 shell 腳本,如下所示。

依賴於 Perl 或 Ruby。 此外,在行更改計數中考慮了空格、重命名和行移動。 只需將其放入一個文件中,並將您的 Git 存儲庫作為第一個參數傳遞。

#!/bin/bash
git --git-dir="$1/.git" log > /dev/null 2> /dev/null
if [ $? -eq 128 ]
then
    echo "Not a git repository!"
    exit 128
else
    echo -e "Lines  | Name\nChanged|"
    git --work-tree="$1" --git-dir="$1/.git" ls-files -z |\
    xargs -0n1 git --work-tree="$1" --git-dir="$1/.git" blame -C -M  -w |\
    cut -d'(' -f2 |\
    cut -d2 -f1 |\
    sed -e "s/ \{1,\}$//" |\
    sort |\
    uniq -c |\
    sort -nr
fi

使用以下命令將日志保存到文件中:

git log --author="<authorname>" --oneline --shortstat > logs.txt

對於 Python 愛好者:

with open(r".\logs.txt", "r", encoding="utf8") as f:
    files = insertions = deletions = 0
    for line in f:
        if ' changed' in line:
            line = line.strip()
            spl = line.split(', ')
            if len(spl) > 0:
                files += int(spl[0].split(' ')[0])
            if len(spl) > 1:
                insertions += int(spl[1].split(' ')[0])
            if len(spl) > 2:
                deletions += int(spl[2].split(' ')[0])

    print(str(files).ljust(10) + ' files changed')
    print(str(insertions).ljust(10) + ' insertions')
    print(str(deletions).ljust(10) + ' deletions')

您的輸出將類似於:

225        files changed
6751       insertions
1379       deletions

對於 Windows 用戶,您可以使用以下批處理腳本來計算指定作者的添加/刪除行

@echo off

set added=0
set removed=0

for /f "tokens=1-3 delims= " %%A in ('git log --pretty^=tformat: --numstat --author^=%1') do call :Count %%A %%B %%C

@echo added=%added%
@echo removed=%removed%
goto :eof

:Count
  if NOT "%1" == "-" set /a added=%added% + %1
  if NOT "%2" == "-" set /a removed=%removed% + %2
goto :eof

https://gist.github.com/zVolodymyr/62e78a744d99d414d56646a5e8a1ff4f

迄今為止我發現的最好的工具是 gitinspector。 它為每個用戶、每周等提供設置報告您可以使用 npm 進行如下安裝

npm install -g gitinspector

獲取更多詳細信息的鏈接

https://www.npmjs.com/package/gitinspector

https://github.com/ejwa/gitinspector/wiki/Documentation

https://github.com/ejwa/gitinspector

示例命令是

gitinspector -lmrTw 
gitinspector --since=1-1-2017 etc

我編寫了這個 Perl 腳本來完成這個任務。

#!/usr/bin/env perl

use strict;
use warnings;

# save the args to pass to the git log command
my $ARGS = join(' ', @ARGV);

#get the repo slug
my $NAME = _get_repo_slug();

#get list of authors
my @authors = _get_authors();
my ($projectFiles, $projectInsertions, $projectDeletions) = (0,0,0);
#for each author
foreach my $author (@authors) {
  my $command = qq{git log $ARGS --author="$author" --oneline --shortstat --no-merges};
  my ($files, $insertions, $deletions) = (0,0,0);
  my @lines = `$command`;
  foreach my $line (@lines) {
    if ($line =~ m/^\s(\d+)\s\w+\s\w+,\s(\d+)\s\w+\([\+|\-]\),\s(\d+)\s\w+\([\+|\-]\)$|^\s(\d+)\s\w+\s\w+,\s(\d+)\s\w+\(([\+|\-])\)$/) {
      my $lineFiles = $1 ? $1 : $4;
      my $lineInsertions = (defined $6 && $6 eq '+') ? $5 : (defined $2) ? $2 : 0;
      my $lineDeletions = (defined $6 && $6 eq '-') ? $5 : (defined $3) ? $3 : 0;
      $files += $lineFiles;
      $insertions += $lineInsertions;
      $deletions += $lineDeletions;
      $projectFiles += $lineFiles;
      $projectInsertions += $lineInsertions;
      $projectDeletions += $lineDeletions;
    }
  }
  if ($files || $insertions || $deletions) {
    printf(
      "%s,%s,%s,+%s,-%s,%s\n",
      $NAME,
      $author,
      $files,
      $insertions,
      $deletions,
      $insertions - $deletions
    );
  }
}

printf(
  "%s,%s,%s,+%s,-%s,%s\n",
  $NAME,
  'PROJECT_TOTAL',
  $projectFiles,
  $projectInsertions,
  $projectDeletions,
  $projectInsertions - $projectDeletions
);

exit 0;

#get the remote.origin.url joins that last two pieces (project and repo folder)
#and removes any .git from the results. 
sub _get_repo_slug {
  my $get_remote_url = "git config --get remote.origin.url";
  my $remote_url = `$get_remote_url`;
  chomp $remote_url;

  my @parts = split('/', $remote_url);

  my $slug = join('-', @parts[-2..-1]);
  $slug =~ s/\.git//;

  return $slug;
}

sub _get_authors {
  my $git_authors = 'git shortlog -s | cut -c8-';
  my @authors = `$git_authors`;
  chomp @authors;

  return @authors;
}

我將它命名為git-line-changes-by-author並放入/usr/local/bin 因為它保存在我的路徑中,所以我可以發出命令git line-changes-by-author --before 2018-12-31 --after 2020-01-01來獲取 2019 年的報告。 舉個例子。 如果我拼錯了名字 git 會建議正確的拼寫。

您可能需要調整_get_repo_slug子僅包括最后部分remote.origin.url我的回購協議被保存為project/repo和你的可能不是。

這里的腳本會做到這一點。 把它放到 authorship.sh 中,chmod +x 它,你就大功告成了。

#!/bin/sh
declare -A map
while read line; do
    if grep "^[a-zA-Z]" <<< "$line" > /dev/null; then
        current="$line"
        if [ -z "${map[$current]}" ]; then 
            map[$current]=0
        fi
    elif grep "^[0-9]" <<<"$line" >/dev/null; then
        for i in $(cut -f 1,2 <<< "$line"); do
            map[$current]=$((map[$current] + $i))
        done
    fi
done <<< "$(git log --numstat --pretty="%aN")"

for i in "${!map[@]}"; do
    echo -e "$i:${map[$i]}"
done | sort -nr -t ":" -k 2 | column -t -s ":"

你想要Git 責備

有一個 --show-stats 選項可以打印一些統計信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM