Skip to content

Instantly share code, notes, and snippets.

@matthewadams
Last active June 6, 2017 20:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewadams/9aeec475cc46297152228c1e8ccca8b0 to your computer and use it in GitHub Desktop.
Save matthewadams/9aeec475cc46297152228c1e8ccca8b0 to your computer and use it in GitHub Desktop.
git log for scrum across multiple repos
#!/usr/bin/env bash
SCRUM_TIME=${SCRUM_TIME-"08:45:00"}
BEFORE_DAY=${BEFORE_DAY-$(date +%Y-%m-%d)}
BEFORE_TIME=${BEFORE_TIME-$SCRUM_TIME}
AFTER_DAY=${AFTER_DAY-$(python -c "from datetime import datetime, timedelta; before = datetime.strptime('$BEFORE_DAY','%Y-%m-%d').date(); monday = before.strftime('%u') == '1'; days = -3 if monday else -1; after = before + timedelta(days=days); print after;")}
AFTER_TIME=${AFTER_TIME-$BEFORE_TIME}
TZ_OFFSET=$(date +%z)
AFTER="${AFTER_DAY}T${AFTER_TIME}${TZ_OFFSET}"
BEFORE="${BEFORE_DAY}T${BEFORE_TIME}${TZ_OFFSET}"
DIR="${DIR-$PWD}"
MAX_DEPTH=${MAX_DEPTH-2}
echo Commits after $AFTER and before $BEFORE:
for repo in $(find "$DIR" -type d -name .git -maxdepth $MAX_DEPTH); do
BACK="$DIR"
cd "$repo/.."
ORIG_BRANCH="$(git branch | grep '*' | awk '{print $2;}')"
if [ -n "$(git status -s)" ]; then
UNSTASH=1
git stash &>/dev/null
fi
for branch in $(git branch | sed 's/*//'); do
git checkout $branch &>/dev/null
LOG="$(git log --author="$(git config user.name)" --after="$AFTER" --before="$BEFORE" --no-merges --pretty=format:'%C(yellow)%h %ai %Cred%d %Creset%s%Cblue [%cn]%Creset' --decorate)"
if [ -n "$LOG" ]; then
echo "$PWD:$branch"
echo "$LOG"
fi
done
git checkout $ORIG_BRANCH &>/dev/null
if [ -n "$UNSTASH" ]; then
git stash pop &>/dev/null
UNSTASH=
ORIG_BRANCH=
fi
cd "$BACK"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment