Skip to content

Instantly share code, notes, and snippets.

@JordanReiter
Last active October 7, 2024 06:50
Show Gist options
  • Save JordanReiter/597046d44182570b8140 to your computer and use it in GitHub Desktop.
Save JordanReiter/597046d44182570b8140 to your computer and use it in GitHub Desktop.
Remind yourself of what you did over the past day and week by reading a summary of all of your git commits.
0 22 * * 1,2,3,4,5 /path/to/git_changes.sh /path/to/projects/ # Sends 5 PM EST if server time is UTC
0 21 * * 5 /path/to/git_changes.sh -w /path/to/projects # Sends Friday @ 4PM EST if server time is UTC
#!/usr/bin/env bash
# Changes
# shebanged
# get author from .gitconfig & make that the recipient
# Instead of hard-coding the directory, make it an argument
if [ "$1" = "-w" ]; then
shift
mailing="weekly"
since="1.week"
format="iso"
else
mailing="daily"
since="1.day"
format="relative"
fi
AUTHOR=$(awk -F "=" '/email/ {print $2}' ~/.gitconfig | tr -d '[[:space:]]')
PROJECTS_DIR=$1
RECIPIENT=$AUTHOR
output=""
for git in $(find $PROJECTS_DIR -maxdepth 2 -name "*.git"); do
gitdir=$(dirname "$git");
cd $gitdir
changes=$(git --no-pager log --date=$format --pretty=format:"%cd: %s" --decorate=short --author=$AUTHOR --since=$since);
if [ "$changes" ]; then
output="$output\n$gitdir:\n$changes\n\n"
fi
done
if [ "$output" ]; then
if [ "$mailing" = "weekly" ]; then
echo -e "$output" | mail -s "Weekly git commits update for week ending $(date +'%b %d')" $RECIPIENT
else
echo -e "$output" | mail -s "git commits for $(date +'%A, %b %d')" $RECIPIENT
fi
fi
@rybak
Copy link

rybak commented Dec 8, 2016

You could add --all to the git log to list commits on all branches, and not just the current one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment