Skip to content

Instantly share code, notes, and snippets.

@tverlaan
Created July 30, 2021 20:59
Show Gist options
  • Save tverlaan/714c33609cc68dc1a33abb8f2d2a6a4d to your computer and use it in GitHub Desktop.
Save tverlaan/714c33609cc68dc1a33abb8f2d2a6a4d to your computer and use it in GitHub Desktop.
Basic script to review commits you just fetched one by one
#!/bin/bash
set -e
CURRENT_VERSION="${1:-HEAD}"
NEXT_VERSION="${2:-FETCH_HEAD}"
echo "Showing commits from $NEXT_VERSION since $CURRENT_VERSION"
COMMIT_COUNT=$(git --no-pager log --format=format:%H $CURRENT_VERSION..$NEXT_VERSION | wc -l)
echo "Commits to review: $COMMIT_COUNT"
echo
echo "$CURRENT_VERSION:"
git --no-pager log -1 $CURRENT_VERSION
echo
echo "$NEXT_VERSION:"
git --no-pager log -1 $NEXT_VERSION
echo
echo "To exit the pager hit Ctrl-C and then press q"
read -p "Continue? [y/n] " -n 1 -r
if [[ ! $REPLY =~ ^[y]$ ]]
then
echo
exit 1
fi
git --no-pager log --reverse --format=format:%H $CURRENT_VERSION..$NEXT_VERSION | \
while read commit;
do
git show -p $commit
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment