Last active
October 7, 2024 06:50
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could add
--all
to thegit log
to list commits on all branches, and not just the current one.