/
git-coderev.sh
executable file
·37 lines (28 loc) · 1.06 KB
/
git-coderev.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#/bin/sh
#
# Compare two revisions of the Git project in the current working
# directory with coderev (http://code.google.com/p/coderev/) to
# produce an HTML report for code review.
#
# Marc Liyanage <http://www.entropy.ch>
#
CODEDIFF=/usr/local/coderev/codediff.py
set -e
REVISION1=$1
[ $REVISION1 ] || { echo Usage: $0 '<old_revision>' '[new_revision]'; echo "new_revision defaults to 'head'"; false; }
REVISION2=$2
[ $REVISION2 ] || { echo using head as new version; REVISION2=head; }
BRANCH=$(git status | grep 'On branch' | sed -e 's/.*branch //')
[ $BRANCH ] || { echo unable to determine branch; false; }
DIR=$(basename "$PWD")
git-export.sh "$REVISION1"
git-export.sh "$REVISION2"
git diff --stat "$REVISION1" "$REVISION2" > /tmp/diffstat.txt
$CODEDIFF \
-o ~/Desktop/"code review $DIR $BRANCH" \
--wrap=130 \
--commentfile=/tmp/diffstat.txt \
--title="Code changes for $DIR $BRANCH" \
~/Desktop/"$REVISION1" ~/Desktop/"$REVISION2"
rm -r ~/Desktop/"$REVISION1" ~/Desktop/"$REVISION2" /tmp/diffstat.txt
find ~/Desktop/"code review $DIR $BRANCH" -type d -empty -delete