Skip to content

Instantly share code, notes, and snippets.

@OzTamir
Last active January 28, 2017 11:06
Show Gist options
  • Save OzTamir/a730286ec67671708822be268e240f36 to your computer and use it in GitHub Desktop.
Save OzTamir/a730286ec67671708822be268e240f36 to your computer and use it in GitHub Desktop.
Summarize your work in a git repository
#!/usr/bin/env bash
###########
# summary.sh
# Summarize your work in a git repository
# Author: Oz Tamir, 30/11/2016, [email protected]
# usage: ./summery.sh FIRSTNAME LASTNAME
############
# Number of lines changed by me
function git_my_work() {
git log --author="$1 $2" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "Added lines: \x1B[32m%s\x1B[37m, removed lines: \x1B[31m%s\x1B[37m, total lines: \x1B[36m%s\x1B[37m\n", add, subs, loc }'
}
echo "$1's Git Summary"
echo '----------------'
# Total commits
printf "Total Commits: \x1B[36m%s\x1B[37m commits.\n" $(git log --author="$1 $2" --reverse | grep 'commit ' -c)
# Total line changes
echo "Total Changes in the code:"
git_my_work
# Time Period
echo "$1's first commit $(git log --author "$1 $2" --reverse | grep 'Date: ' | head -1)"
echo "$1's last commit $(git log --author "$1 $2" --reverse | grep 'Date: ' | tail -1)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment