Skip to content

Instantly share code, notes, and snippets.

@kevbook
Forked from lexqt/git_stats.sh
Created January 30, 2018 06:12

Revisions

  1. @lexqt lexqt revised this gist May 17, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git_stats.sh
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ AUTHOR=$2 # author pattern (regexp)
    if [[ $AUTHOR ]]
    then
    # detailed stats for an individual
    git log --shortstat --author=$AUTHOR --since=$DATE | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed: ", files, "\nlines inserted: ", inserted, "\nlines deleted: ", deleted}'
    git log --shortstat --author="$AUTHOR" --since=$DATE | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed: ", files, "\nlines inserted: ", inserted, "\nlines deleted: ", deleted}'
    fi

    # commit numbers by author for the repo
  2. @lexqt lexqt renamed this gist May 17, 2012. 1 changed file with 18 additions and 4 deletions.
    22 changes: 18 additions & 4 deletions stats.sh → git_stats.sh
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,25 @@
    # detailed stats for an individual
    git log --shortstat --author=AUTHOR --since=10-1-2011 | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed: ", files, "\nlines inserted: ", inserted, "\nlines deleted: ", deleted}'
    #!/bin/bash

    if [[ $1 == "" && $2 == "" ]]
    then
    echo "USAGE: $0 SINCE_DATE [AUTHOR_PATTERN]"
    exit
    fi

    DATE=$1 # 10-1-2011, 2012-04-22, etc
    AUTHOR=$2 # author pattern (regexp)

    if [[ $AUTHOR ]]
    then
    # detailed stats for an individual
    git log --shortstat --author=$AUTHOR --since=$DATE | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed: ", files, "\nlines inserted: ", inserted, "\nlines deleted: ", deleted}'
    fi

    # commit numbers by author for the repo
    git log --pretty=format:%an --since=10-1-2011 | awk '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }' | sort -r
    git log --pretty=format:%an --since=$DATE | awk '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }' | sort -r

    # detailed stats per author, including contribution to the total change
    git log --numstat --since=10-1-2011 | awk '
    git log --numstat --since=$DATE | awk '
    function printStats(author) {
    printf "%s:\n", author
    printf " insertions: %d (%.0f%%)\n", more[author], (more[author] / more["total"] * 100)
  3. @lonnen lonnen revised this gist Dec 28, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions stats.sh
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    # stats for an individual
    # detailed stats for an individual
    git log --shortstat --author=AUTHOR --since=10-1-2011 | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed: ", files, "\nlines inserted: ", inserted, "\nlines deleted: ", deleted}'

    # commit numbers by author for the repo
    git log --pretty=format:%an --since=10-1-2011 | awk '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }' | sort -r

    # detailed by author stats, including contribution to the total change
    # detailed stats per author, including contribution to the total change
    git log --numstat --since=10-1-2011 | awk '
    function printStats(author) {
    printf "%s:\n", author
  4. @lonnen lonnen created this gist Dec 28, 2011.
    40 changes: 40 additions & 0 deletions stats.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    # stats for an individual
    git log --shortstat --author=AUTHOR --since=10-1-2011 | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed: ", files, "\nlines inserted: ", inserted, "\nlines deleted: ", deleted}'

    # commit numbers by author for the repo
    git log --pretty=format:%an --since=10-1-2011 | awk '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }' | sort -r

    # detailed by author stats, including contribution to the total change
    git log --numstat --since=10-1-2011 | awk '
    function printStats(author) {
    printf "%s:\n", author
    printf " insertions: %d (%.0f%%)\n", more[author], (more[author] / more["total"] * 100)
    printf " deletions: %d (%.0f%%)\n", less[author], (less[author] / less["total"] * 100)
    printf " files: %d (%.0f%%)\n", file[author], (file[author] / file["total"] * 100)
    printf " commits: %d (%.0f%%)\n", commits[author], (commits[author] / commits["total"] * 100)
    }
    /^Author:/ {
    author = $2 " " $3
    commits[author] += 1
    commits["total"] += 1
    }
    /^[0-9]/ {
    more[author] += $1
    less[author] += $2
    file[author] += 1
    more["total"] += $1
    less["total"] += $2
    file["total"] += 1
    }
    END {
    for (author in commits) {
    if (author != "total") {
    printStats(author)
    }
    }
    printStats("total")
    }'