Skip to content

Commit 6792b57

Browse files
committed
Merge pull request scala#4765 from janekdb/2.11.x-scaladoc-diff
Script to compare the current scaladoc with the parent commit's doc
2 parents cc90f77 + 006c0a4 commit 6792b57

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed

tools/scaladoc-diff

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Script to compare the scaladoc of the current commit with the scaladoc
4+
# of the parent commit. No arguments.
5+
#
6+
7+
set -e
8+
9+
# opendiff for Mac OS X, meld for Ubuntu then default to other commands.
10+
displaydiff() {
11+
case "$(uname -s)" in
12+
13+
Darwin)
14+
if hash opendiff 2>/dev/null; then
15+
echo opendiff "$@"
16+
opendiff "$@"
17+
else
18+
echo diff "$@"
19+
diff -y "$@" | less -N
20+
fi
21+
;;
22+
23+
*)
24+
if hash meld 2>/dev/null; then
25+
echo meld "$@"
26+
meld "$@"
27+
elif hash gvimdiff 2>/dev/null; then
28+
echo gvimdiff "$@"
29+
gvimdiff "$@"
30+
else
31+
echo diff "$@"
32+
diff -y "$@" | less -N
33+
fi
34+
;;
35+
esac
36+
}
37+
38+
oldsha=$(git rev-parse --short HEAD^)
39+
40+
# Use branch name defaulting to SHA1 when not available for example when in
41+
# detached HEAD state.
42+
sha=$(git symbolic-ref -q --short HEAD || git rev-parse --short HEAD)
43+
44+
echo "parent commit sha : $oldsha"
45+
echo "current commit sha : $sha"
46+
47+
# create scaladoc for parent commit if not done already
48+
if [ ! -f "build/scaladoc-output-$oldsha.txt" ]
49+
then
50+
echo "making scaladoc for parent commit ($oldsha)"
51+
git checkout -q $oldsha
52+
ant docs.lib -Dscaladoc.raw.output='yes' > build/scaladoc-output-$oldsha.txt
53+
rm -rf build/scaladoc-${oldsha}
54+
mv build/scaladoc build/scaladoc-${oldsha}
55+
git checkout -q $sha
56+
fi
57+
58+
# create scaladoc for current commit
59+
echo "making scaladoc for current commit ($sha)"
60+
ant docs.lib -Dscaladoc.raw.output='yes' > build/scaladoc-output-$sha.txt
61+
rm -rf build/scaladoc-${sha}
62+
mv build/scaladoc build/scaladoc-${sha}
63+
64+
# Allow script to continue when diff results in -1
65+
set +e
66+
67+
displaydiff build/scaladoc-output-$oldsha.txt build/scaladoc-output-$sha.txt
68+
69+
# Adapted from tools/scaladoc-compare
70+
echo "Comparing versions with diff: build/scaladoc-${sha}/ build/scaladoc-$oldsha/"
71+
NEW_PATH=build/scaladoc-${sha}/
72+
OLD_PATH=build/scaladoc-$oldsha/
73+
74+
75+
NEWFILES=$(find $NEW_PATH -name '*.html.raw')
76+
if [ "$NEWFILES" == "" ]
77+
then
78+
echo "No .html.raw files found in $NEW_PATH!"
79+
exit 1
80+
fi
81+
82+
for NEW_FILE in $NEWFILES
83+
do
84+
OLD_FILE=${NEW_FILE/$NEW_PATH/$OLD_PATH}
85+
if [ -f $OLD_FILE ]
86+
then
87+
DIFF=$(diff -q -w $NEW_FILE $OLD_FILE 2>&1)
88+
if [ "$DIFF" != "" ]
89+
then
90+
displaydiff $OLD_FILE $NEW_FILE > /dev/null
91+
92+
echo "next [y\N]? "
93+
read -n 1 -s input
94+
if [ "$input" == "N" ]; then exit 0; fi
95+
fi
96+
else
97+
echo
98+
echo "New file: : $NEW_FILE"
99+
echo "No corresponding old file : $OLD_FILE"
100+
101+
echo "next [y\N]? "
102+
read -n 1 -s input
103+
if [ "$input" == "N" ]; then exit 0; fi
104+
fi
105+
done
106+
107+
OLDFILES=$(find $OLD_PATH -name '*.html.raw')
108+
for OLD_FILE in $OLDFILES
109+
do
110+
NEW_FILE=${OLD_FILE/$OLD_PATH/$NEW_PATH}
111+
if [ ! -f $NEW_FILE ]
112+
then
113+
echo
114+
echo "Old file: : $OLD_FILE"
115+
echo "No corresponding new file : $NEW_FILE"
116+
fi
117+
done

0 commit comments

Comments
 (0)