Created
August 14, 2025 05:13
-
-
Save michaelneale/6e9f7a5d27942a89a38f2221554a5d84 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
# Git Work Summary Script | |
echo "=========================================" | |
echo "GIT WORK SUMMARY" | |
echo "=========================================" | |
echo "" | |
# Get current git user | |
GIT_USER_NAME=$(git config user.name) | |
GIT_USER_EMAIL=$(git config user.email) | |
echo "User: $GIT_USER_NAME <$GIT_USER_EMAIL>" | |
echo "Branch: $(git branch --show-current 2>/dev/null || echo 'unknown')" | |
echo "" | |
AUTHOR_FILTER="${GIT_USER_NAME:-$GIT_USER_EMAIL}" | |
if [ -z "$AUTHOR_FILTER" ]; then | |
echo "Error: No git user configured" | |
exit 1 | |
fi | |
# Stats | |
echo "LAST 30 DAYS STATS:" | |
echo "-------------------" | |
COMMIT_COUNT=$(git log --author="$AUTHOR_FILTER" --since="30 days ago" --oneline 2>/dev/null | wc -l | tr -d ' ') | |
FILE_COUNT=$(git log --author="$AUTHOR_FILTER" --since="30 days ago" --name-only --pretty=format: 2>/dev/null | sort -u | grep -v '^$' | wc -l | tr -d ' ') | |
echo "Commits: $COMMIT_COUNT" | |
echo "Files touched: $FILE_COUNT" | |
echo "" | |
# Files with commit messages | |
echo "FILES MODIFIED WITH COMMIT MESSAGES:" | |
echo "-------------------------------------" | |
# Get all files modified in last 30 days with their commit messages | |
git log --author="$AUTHOR_FILTER" --since="30 days ago" --name-only --pretty=format:"COMMIT:%h|%s" 2>/dev/null | \ | |
awk ' | |
/^COMMIT:/ { | |
split($0, parts, "|") | |
commit_hash = substr(parts[1], 8) | |
commit_msg = parts[2] | |
next | |
} | |
/^$/ { next } | |
{ | |
if (commit_hash) { | |
if (files[$0]) { | |
files[$0] = files[$0] "\n " commit_hash " - " commit_msg | |
} else { | |
files[$0] = " " commit_hash " - " commit_msg | |
} | |
} | |
} | |
END { | |
for (file in files) { | |
print "\n" file ":" | |
print files[file] | |
} | |
} | |
' | head -100 | |
echo "" | |
echo "" | |
# Directory summary | |
echo "DIRECTORIES TOUCHED (by file count):" | |
echo "------------------------------------" | |
git log --author="$AUTHOR_FILTER" --since="30 days ago" --name-only --pretty=format: 2>/dev/null | \ | |
grep -v '^$' | \ | |
while read file; do | |
dirname "$file" | |
done | \ | |
sort | uniq -c | sort -rn | head -10 | \ | |
while read count dir; do | |
printf "%4d %s\n" "$count" "$dir" | |
done | |
echo "" | |
# File types | |
echo "FILE TYPES:" | |
echo "-----------" | |
git log --author="$AUTHOR_FILTER" --since="30 days ago" --name-only --pretty=format: 2>/dev/null | \ | |
grep -v '^$' | \ | |
while read file; do | |
ext="${file##*.}" | |
if [ "$ext" != "$file" ]; then | |
echo ".$ext" | |
fi | |
done | \ | |
sort | uniq -c | sort -rn | \ | |
while read count ext; do | |
printf "%4d %s\n" "$count" "$ext" | |
done | |
echo "" | |
# Current status | |
echo "UNCOMMITTED:" | |
echo "------------" | |
STAGED=$(git diff --cached --numstat 2>/dev/null | wc -l | tr -d ' ') | |
UNSTAGED=$(git diff --numstat 2>/dev/null | wc -l | tr -d ' ') | |
UNTRACKED=$(git ls-files --others --exclude-standard 2>/dev/null | wc -l | tr -d ' ') | |
echo "Staged: $STAGED | Unstaged: $UNSTAGED | Untracked: $UNTRACKED" | |
echo "" | |
echo "=========================================" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment