Jak policzyć wszystkie linie zmienione przez konkretnego autora w repozytorium Git?

Czy istnieje Komenda, którą mogę wywołać, która zliczy wiersze zmienione przez konkretnego autora w repozytorium Git? Wiem, że muszą być sposoby na zliczenie liczby commitów, ponieważ Github robi to dla ich wykresu wpływu.

Author: Peter Perháč, 2009-08-12

21 answers

Wyjście następującego polecenia powinno być dość łatwe do wysłania do skryptu, aby zsumować Sumy:

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

To daje statystyki dla wszystkich commitów na bieżącej głowie. Jeśli chcesz dodać statystyki w innych gałęziach, musisz dostarczyć je jako argumenty do git log.

Aby przejść do skryptu, usunięcie nawet formatu "oneline" można zrobić pustym formatem dziennika, a jak skomentował Jakub Narębski, --numstat jest inną alternatywą. Generuje na plik, a nie na linię statystyki, ale jest jeszcze łatwiejsze do przeanalizowania.

git log --author="<authorname>" --pretty=tformat: --numstat
 247
Author: CB Bailey,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2009-08-12 12:32:30

To daje pewne statystyki dotyczące autora, zmodyfikować zgodnie z wymaganiami.

Using 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 }' -

Używanie Awk na Mac OSX:

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 }' -

Edycja (2017)

Jest nowy pakiet na GitHubie, który wygląda ślisko i używa Basha jako zależności (testowane na Linuksie). Bardziej nadaje się do bezpośredniego użycia niż skryptów.

To git-quick-stats (github link).

Skopiuj git-quick-stats do folderu i Dodaj folder do / align = "left" /

mkdir ~/source
cd ~/source
git clone [email protected]: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

Użycie:

git-quick-stats

Tutaj wpisz opis obrazka

 493
Author: Alex,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-03-03 12:41:15

Gdyby ktoś chciał zobaczyć statystyki dla KAŻDEGO Użytkownika w swojej bazie kodowej, kilku moich współpracowników niedawno wymyśliło ten przerażający jeden-liner:

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";}'

(przejście przez nasz repo, który ma około 10-15k commitów, zajmuje kilka minut.)

 160
Author: Dan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-12-06 01:49:25

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

Jest miłym narzędziem do obliczania liczby dla wszystkich autorów jednocześnie, w tym commitów i zmodyfikowanych plików:

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

Istnieje również wersja Pythona na https://github.com/casperdcl/git-fame (wspomniany przez @fraz):

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

Przykładowe wyjście:

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    |
+------------------------+--------+---------+-------+--------------------+

Ale ostrzegam: jak wspomniał Jared w komentarzu, zrobienie tego na bardzo dużym repozytorium zajmie wiele godzin. Nie wiem, czy to może być Poprawiono jednak, biorąc pod uwagę, że musi przetwarzać tyle danych z Gita.

 119
Author: Ciro Santilli 新疆改造中心 六四事件 法轮功,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-11-17 11:57:14

Okazało się, że przydatne jest, aby zobaczyć, kto ma najwięcej linii, które obecnie znajdują się w bazie kodu:

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

Inne odpowiedzi skupiały się głównie na liniach zmienionych w commitach, ale jeśli commity nie przetrwają i zostaną nadpisane, mogą po prostu zostać wycofane. Powyższe zaklęcie pozwala również posortować wszystkich członków po liniach, a nie po kolei. Możesz dodać kilka opcji do git blame (- C-M), aby uzyskać kilka lepszych liczb, które biorą ruch plików i ruch linii między plików na koncie, ale polecenie może działać znacznie dłużej, jeśli to zrobisz.

Również, jeśli szukasz linii zmienionych we wszystkich commitach dla wszystkich commitów, poniższy mały skrypt jest pomocny:

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

 100
Author: mmrobins,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-10-17 16:35:49

Aby zliczyć liczbęcommitów przez danego autora (lub wszystkich autorów) na danej gałęzi, możesz użyć git-shortlog; Zobacz zwłaszcza jego opcje --numbered i --summary, np. podczas uruchamiania w repozytorium 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
 77
Author: Jakub Narębski,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-09-17 07:34:34

Po spojrzeniu na Alexa i Gerty3000 's odpowiedź, próbowałem skrócić jednolinijkowy:

Zasadniczo, używając git log numstat i NIE śledzenie liczby plików zmienionych.

Git w wersji 2.1.0 na Mac OSX:

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

Przykład:

Jared Burrows   added lines: 6826, removed lines: 2825, total lines: 4001
 63
Author: Jared Burrows,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-09-16 18:38:21

ODPOWIEDŹ z AaronM używanie powłoki one-liner jest dobre, ale w rzeczywistości jest jeszcze jeden błąd, gdzie spacje będą zniekształcać nazwy użytkowników, Jeśli między nazwą użytkownika a datą są różne ilości białych spacji. Uszkodzone nazwy użytkowników dadzą wiele wierszy dla liczby użytkowników i musisz je podsumować samodzielnie.

Ta mała zmiana naprawiła problem dla mnie:

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

Zwróć uwagę na + after \s, które pochłonie wszystkie spacje od nazwy do Data.

Faktycznie dodaję tę odpowiedź tak samo dla własnej pamięci, jak dla pomagania komukolwiek, bo to przynajmniej drugi raz, kiedy googluję temat:)

 23
Author: Erik Zivkovic,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 12:03:05

@ mmrobins @AaronM @ErikZ @JamesMishra dostarczył warianty, które mają wspólny problem: proszą git o wytworzenie mieszanki informacji nie przeznaczonych do użycia skryptów, w tym zawartości linii z repozytorium w tej samej linii, a następnie dopasowanie bałaganu z wyrażeniem regularnym.

Jest to problem, gdy niektóre linie nie są poprawnym tekstem UTF-8, a także gdy niektóre linie zgadzają się z wyrażeniem regularnym (stało się to tutaj).

Oto zmodyfikowana linia, która nie ma tych problemów. It requests git wyświetla dane na osobnych liniach, co ułatwia filtrowanie tego, co chcemy:

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

Możesz grepować inne ciągi znaków, takie jak autor-mail, committer itp.

Być może najpierw wykonaj export LC_ALL=C (zakładając bash), aby wymusić przetwarzanie na poziomie bajtów (zdarza się to również znacznie przyspieszyć grep z lokalizacji opartych na UTF-8).

 20
Author: Stéphane Gourichon,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-04-08 20:39:30

Oto krótki jednowiersz, który tworzy statystyki dla wszystkich autorów. Jest znacznie szybszy niż rozwiązanie dana powyżej w https://stackoverflow.com/a/20414465/1102119 (mine ma złożoność czasową O (N) zamiast o (NM), gdzie N to liczba commitów, A M liczba autorów).

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
 19
Author: kccqzy,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 12:10:40

Rozwiązanie zostało podane z Rubim w środku, perl jest trochę bardziej dostępny domyślnie tutaj jest alternatywą używającą Perla dla bieżących linii przez autora.

git ls-files -z | xargs -0n1 git blame -w | perl -n -e '/^.*\((.*?)\s*[\d]{4}/; print $1,"\n"' | sort -f | uniq -c | sort -n
 16
Author: AaronM,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-03-19 19:38:56

Oprócz odpowiedzi Charles Bailey , możesz dodać parametr -C do poleceń. W przeciwnym razie zmiany nazw plików liczą się jako wiele dodatków i usunięć (tyle, ile plik ma linii), nawet jeśli zawartość pliku nie została zmodyfikowana.

Dla zilustrowania, oto commit z wieloma plikami przenoszonymi z jednego z moich projektów, gdy używam komendy git log --oneline --shortstat:

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

I tutaj ten sam commit za pomocą komendy git log --oneline --shortstat -C która wykrywa kopie plików i zmiana nazwy:

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

Moim zdaniem ta ostatnia daje bardziej realistyczny obraz wpływu, jaki dana osoba miała na projekt, ponieważ zmiana nazwy pliku jest o wiele mniejszą operacją niż zapisanie pliku od zera.

 14
Author: Esko Luontola,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 12:34:45

Oto szybki skrypt ruby, który porównuje wpływ każdego użytkownika na dane zapytanie dziennika.

Na przykład dla rubinius :

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

Scenariusz:

#!/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
 11
Author: Nevir,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-03-20 07:00:48

Podałem modyfikację krótkiej odpowiedzi powyżej, ale nie była ona wystarczająca dla moich potrzeb. Musiałem być w stanie skategoryzować zarówno linie, jak i linie w kodzie końcowym. Chciałem też rozbić akta. Ten kod nie rekurencyjnie, zwróci tylko wyniki dla jednego katalogu, ale jest to dobry początek, jeśli ktoś chciał pójść dalej. Skopiuj i wklej do pliku i utwórz plik wykonywalny lub uruchom go za pomocą Perla.

#!/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};
}
 5
Author: AaronM,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-09-28 23:26:17

Jest to najlepszy sposób i daje jasny obraz całkowitej liczby commitów wszystkich użytkowników

git shortlog -s -n
 5
Author: edrich13,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-02-17 05:52:59

Możesz użyć whoid ( https://www.npmjs.com/package/whodid )

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

I

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

Lub po prostu wpisz

$ whodid

Następnie możesz zobaczyć wynik w ten sposób

Contribution state
=====================================================
 score  | author
-----------------------------------------------------
 3059   | someguy <[email protected]>
 585    | somelady <[email protected]>
 212    | niceguy <[email protected]>
 173    | coolguy <[email protected]>
=====================================================
 4
Author: victor.cheval,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-07-20 15:34:11

Ten skrypt to zrobi. Put it into authorship.sh, chmod + x to, i wszystko gotowe.

#!/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 ":"
 1
Author: ZX2C4,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-12-11 19:44:54

Zapisz swoje logi do pliku używając:

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

Dla miłośników Pythona:

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')

Twoje wyniki będą takie:

225        files changed
6751       insertions
1379       deletions
 1
Author: Amen Ayach,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-03-25 23:01:23

You want Git blame .

Jest opcja -- show-stats, aby wydrukować niektóre, cóż, statystyki.

 0
Author: gbjbaanb,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2009-08-12 09:07:57

Pytanie wymagało informacji o konkretnym autorze , ale wiele odpowiedzi było rozwiązaniami, które zwracały rankingowe listy autorów na podstawie zmienionych linii kodu.

Tego właśnie szukałem, ale istniejące rozwiązania nie były do końca idealne. W interesie ludzi, którzy mogą znaleźć to pytanie za pośrednictwem Google, zrobiłem kilka ulepszeń na nich i uczynił je w skrypcie powłoki, które wyświetlam poniżej. Z adnotacją (którą będę nadal utrzymywać) można znaleźć na moim Githubie .

Nie ma zależności ani od Perla, ani Rubiego. Co więcej, białe znaki, zmiany nazw i ruchy linii są brane pod uwagę w liczniku zmian linii. Wystarczy umieścić to w pliku i przekazać swoje repozytorium Git jako pierwszy parametr.

#!/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
 0
Author: James Mishra,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-05-31 18:05:01

Najlepszym narzędziem do tej pory udało mi się zidentyfikować jest gitinspector. Daje raport set NA użytkownika, na tydzień itp Możesz zainstalować Jak Poniżej za pomocą npm

Npm install-g gitinspector

Linki, aby uzyskać więcej szczegółów

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

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

Https://github.com/ejwa/gitinspector

Przykładowe polecenia to

gitinspector -lmrTw 
gitinspector --since=1-1-2017 etc
 0
Author: Ravikiran Reddy Kotapati,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-03-13 09:42:55