#!/bin/zsh # # Review commits based on the branch graph # command p = move to previous commit # command / = move by searching text # command ? = show commit details N=1 if [ $# = 1 ] ; then if [ -e $1 ] ; then FOCUS=$1 else N=$1 fi elif [ $# = 2 ] ; then N=$1 FOCUS=$2 fi FMT='--pretty=format:%h [%aN/%as]%d %s' GRAPH="$(git log --graph --full-history "$FMT" --all $FOCUS )" PROJECT="$(git rev-parse --show-toplevel| sed 's/.*\///')" X=$(echo "$GRAPH"q | iselect -t "$PROJECT" -n git-review -p $N -P -K -k/ -k\? -kp ) [ -z "$X" ] && exit 0 X=( ${(s[:])X} ) N=$X[1] K=$X[2] X=$X[3] if [ "$K" = / ] ; then read "x?Search: " N=${"$(echo "$GRAPH" | grep -anF "$x")"%%:*} elif [ "$K" = "p" ] ; then # previous commit Z=${"$(git rev-parse ${X}~1)"[1,7]} [ -z "$Z" ] || N=${"$(echo "$GRAPH" | grep -nF "$Z")"%%:*} elif [ "$K" = "?" ] ; then git log --no-walk --notes --show-signature --pretty=fuller "$X" | less else FOCUS=$FOCUS git-show-i $X~1 $X fi exec $0 $N $FOCUS