#! /bin/bash # # Shell script to massage the output of a recursive diff # into a format which can be used for code reviews. # # Author: Mitch Davis . # License: Public domain, no rights reserved. # # Credits: Loosely based on an earlier program by Denis Dowling, # # # TODO: Put in a trap to clean up temporary files. # TODO: The good thing about the subpatch approach was that # you could reorder patches, for instance, .c and .h files. # # Version: 2.3 Tue Feb 12 16:10:43 2002 VERSION=2.3 stderr() { echo "$*" 1>&2 } error() { stderr "$0: $*" rm -f /tmp/mrd-*-$$ exit 1 } # Alter the heading of each diff. fixdiff() { awk ' BEGIN { in_header = 0; LINENO = 1; } { LINE=$0 } in_header > 0 { if (in_header == 2) { vars = split($0, VAR); printf " #### Changes to file %s\n", VAR[2]; printf "%-60s %5d\n", $2, LINENO; } in_header--; gsub(/\t.*/, ""); suppress_numbers = 1; } /^diff / { in_header = 2; next; } { if (suppress_numbers == 1) { printf " %s\n", $0; } else { printf " %4d %s\n", LINENO++, $0; } suppress_numbers = 0; } END { printf " #### Done.\n"; } ' } show_changed() { grep "^[^ ]" | \ awk ' NR==1 {printf "A"} {printf "\t%s\n", $0} ' } # main content=/tmp/mrd-content-$$ fixdiff > $content # Build the summary echo " Code Review File" echo " Created by $USER, using makereviewdiff $VERSION" echo " Created on `date`" echo " Script run from directory `pwd`" echo echo "P3142 EXPANdsl R2 Implementation" echo echo '*** DO NOT FORGET TO TAG THE REPOSITORY BEFORE CHECKINS ***' echo echo " -------- Change comments -------" echo "A: " echo echo " ------------ Summary -----------" echo " ---- Changed Files ----" show_changed < $content echo " --------- End of Summary -------" echo grep -v "^[^ ]" < $content # Delete the temporary files. FSPEC="/tmp/mrd-*-$$" rm $FSPEC exit 0