Skip to content

Instantly share code, notes, and snippets.

@npotier
Created December 10, 2014 22:05
Show Gist options
  • Save npotier/6bef8798136f78d9b534 to your computer and use it in GitHub Desktop.
Save npotier/6bef8798136f78d9b534 to your computer and use it in GitHub Desktop.
Gitlab stats
# Dirty command line used to scan each gitlab repository and extract some stats
# in this case : foreach commit > 2014-01-01 get the number of commmits, number of line added, deleted grouped by users
rm /tmp/stats2014.csv; find /home/git/repositories -name .git -prune -o -name '*.git' -print | while read directory; do cd $directory; git log --after="2014-01-01" --format='%aN' |sort -u | while read name; do echo -en "Project\t$directory\t" >> /tmp/stats2014.csv; echo -en "Author\t$name\t" >> /tmp/stats2014.csv; git log --after="2014-01-01" --after="2014-01-01" --author="$name" --pretty=format:%ae | gawk -- '{ ++c; } END { printf "Number of commits\t%s\t",c; }' >> /tmp/stats2014.csv; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "Added lines\t%s\tRemoved lines\t%s\tTotal lines\t%s\n", add, subs, loc }' >> /tmp/stats2014.csv; done; done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment