Stefan Saasen avatar Stefan Saasen committed d2298bf

Add the 'git stats' command

Comments (0)

Files changed (2)

+#!/bin/bash
+
+set -e
+
+# actually parse the options and do stuff
+while [[ $1 = -?* ]]; do
+    case $1 in
+        --gc)
+            echo "Repacking objects"
+            git gc --aggressive --auto
+            ;;
+        *) ;;
+    esac
+
+shift
+done
+
+# Summarize information about the current git repository
+NUMBER_OF_COMMITS=`git rev-list --all | wc -l`
+NUMBER_OF_OBJECTS=`git count-objects -v | grep in-pack | cut -f 2 -d ':'`
+NUMBER_OF_FILES=`git ls-files | wc -l | tr -d ' '`
+NUMBER_OF_CONTRIBUTORS=`git shortlog -s -n | wc -l | tr -d ' '`
+AGE=`git log --reverse --format='%cr' | head -n 1`
+
+
+# %'.3f\n
+printf "Number of contributors: %'12.d\n" $NUMBER_OF_CONTRIBUTORS
+printf "Number of commits     : %'12.d\n" $NUMBER_OF_COMMITS
+printf "Number of objects     : %'12.d\n" $NUMBER_OF_OBJECTS
+printf "Number of files       : %'12.d\n" $NUMBER_OF_FILES
+printf "First commit          : %12s\n" "$AGE"
+.\" Manpage for git-stats
+.TH man 1 "September 2012" "1.0" "git stats man page"
+.SH NAME
+git stats\- Show repository statistics
+.SH SYNOPSIS
+git activity [--gc]
+.SH DESCRIPTION
+Show basic statistics about the current repository. This command will list the
+number of commits, files, objects and contributors and the age of the
+repository.
+.SH OPTIONS
+.TP
+.I --gc
+Run aggressive gc to get a more accurate object count.
+.SH BUGS
+No known bugs.
+.SH AUTHOR
+Stefan Saasen <stefan@saasen.me>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.