Skip to content

Instantly share code, notes, and snippets.

@sposmen
Created February 13, 2026 17:11
Show Gist options
  • Select an option

  • Save sposmen/a104f8fdb2e1c0d5bfe6875029921153 to your computer and use it in GitHub Desktop.

Select an option

Save sposmen/a104f8fdb2e1c0d5bfe6875029921153 to your computer and use it in GitHub Desktop.
Get Authors dates frame.
#!/bin/bash
# Ensure we're inside a git repository
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
echo "Error: This is not a git repository."
exit 1
fi
TMP_FILE=$(mktemp)
# Get unique list of authors (name + email)
git log --format="%an|%ae" | sort -u | while IFS="|" read NAME EMAIL
do
FIRST_COMMIT=$(git log --author="$EMAIL" --reverse --format="%at" | head -n 1)
LAST_COMMIT=$(git log --author="$EMAIL" --format="%at" | head -n 1)
if [ -z "$FIRST_COMMIT" ]; then
continue
fi
DIFF_SECONDS=$((LAST_COMMIT - FIRST_COMMIT))
DIFF_DAYS=$((DIFF_SECONDS / 86400))
DIFF_HOURS=$(( (DIFF_SECONDS % 86400) / 3600 ))
DIFF_MINUTES=$(( (DIFF_SECONDS % 3600) / 60 ))
TOTAL_COMMITS=$(git log --author="$EMAIL" --oneline | wc -l)
# Guardamos todo en el tmp con FIRST_COMMIT como clave de ordenación
echo "$FIRST_COMMIT|$NAME|$EMAIL|$LAST_COMMIT|$DIFF_DAYS|$DIFF_HOURS|$DIFF_MINUTES" >> "$TMP_FILE"
done
# Ordenamos por el timestamp del primer commit
sort -n "$TMP_FILE" | while IFS="|" read FIRST NAME EMAIL LAST DIFF_DAYS DIFF_HOURS DIFF_MINUTES
do
FIRST_DATE=$(date -r "$FIRST")
LAST_DATE=$(date -r "$LAST")
echo "Author: $NAME <$EMAIL>, $FIRST_DATE - $LAST_DATE, $DIFF_DAYS days, $DIFF_HOURS hours, $DIFF_MINUTES minutes"
done
rm "$TMP_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment