Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Scan git repos and produce a time-sorted, consolidated log. (Hint: edit the variables in this.)
#! /bin/bash
# git-log-consolidate
set -e
SINCE="Aug 25"
UNTIL="Sep 19"
LOG=~/git-log-consolidated.log
TMP=$LOG.tmp
gather() {
set -e
XOX=$(basename $GIT_DIR)
if [ "$XOX" = ".git" ]
then XOX=$(basename $(dirname $GIT_DIR))
fi
git log --format=format:"%ai [XOX] %s" --since="$SINCE" --until="$UNTIL" | sed -e"s/XOX/$XOX/"
}
PROJECTS="current"
echo -n > $TMP
export GIT_DIR
for root in $PROJECTS
do
for d in $(find ~/projects/$root -type d -name objects)
do
GIT_DIR=$(dirname $d)
if [ -e $GIT_DIR/index ]
then
echo $GIT_DIR
gather >> $TMP
echo >> $TMP
fi
done
done
sort -u < $TMP > $LOG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment