File: scaladoc-diff

package info (click to toggle)
scala 2.11.12-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 62,828 kB
  • sloc: javascript: 28,808; java: 13,415; xml: 3,250; sh: 1,620; python: 756; makefile: 38; awk: 36; ansic: 6
file content (117 lines) | stat: -rwxr-xr-x 2,876 bytes parent folder | download | duplicates (3)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bash
#
# Script to compare the scaladoc of the current commit with the scaladoc
# of the parent commit. No arguments.
#

set -e

# opendiff for Mac OS X, meld for Ubuntu then default to other commands.
displaydiff() {
  case "$(uname -s)" in

    Darwin)
      if hash opendiff 2>/dev/null; then
        echo opendiff "$@"
        opendiff "$@"
      else
        echo diff "$@"
        diff -y "$@" | less -N
      fi
    ;;

    *)
      if hash meld 2>/dev/null; then
        echo meld "$@"
        meld "$@"
      elif hash gvimdiff 2>/dev/null; then
        echo gvimdiff "$@"
        gvimdiff "$@"
      else
        echo diff "$@"
        diff -y "$@" | less -N
      fi
    ;;
  esac
}

oldsha=$(git rev-parse --short HEAD^)

# Use branch name defaulting to SHA1 when not available for example when in
# detached HEAD state.
sha=$(git symbolic-ref -q --short HEAD || git rev-parse --short HEAD)

echo "parent commit sha  : $oldsha"
echo "current commit sha : $sha"

# create scaladoc for parent commit if not done already
if [ ! -f "build/scaladoc-output-$oldsha.txt" ]
then
  echo "making scaladoc for parent commit ($oldsha)"
  git checkout -q $oldsha
  ant docs.lib -Dscaladoc.raw.output='yes' > build/scaladoc-output-$oldsha.txt
  rm -rf build/scaladoc-${oldsha}
  mv build/scaladoc build/scaladoc-${oldsha}
  git checkout -q $sha
fi

# create scaladoc for current commit
echo "making scaladoc for current commit ($sha)"
ant docs.lib -Dscaladoc.raw.output='yes' > build/scaladoc-output-$sha.txt
rm -rf build/scaladoc-${sha}
mv build/scaladoc build/scaladoc-${sha}

# Allow script to continue when diff results in -1
set +e

displaydiff build/scaladoc-output-$oldsha.txt build/scaladoc-output-$sha.txt

# Adapted from tools/scaladoc-compare
echo "Comparing versions with diff: build/scaladoc-${sha}/ build/scaladoc-$oldsha/"
NEW_PATH=build/scaladoc-${sha}/
OLD_PATH=build/scaladoc-$oldsha/


NEWFILES=$(find $NEW_PATH -name '*.html.raw')
if [ "$NEWFILES" == "" ]
then
  echo "No .html.raw files found in $NEW_PATH!"
  exit 1
fi

for NEW_FILE in $NEWFILES
do
  OLD_FILE=${NEW_FILE/$NEW_PATH/$OLD_PATH}
  if [ -f $OLD_FILE ]
  then
    DIFF=$(diff -q -w $NEW_FILE $OLD_FILE 2>&1)
    if [ "$DIFF" != "" ]
    then
      displaydiff $OLD_FILE $NEW_FILE > /dev/null

      echo "next [y\N]? "
      read -n 1 -s input
      if [ "$input" == "N" ]; then exit 0; fi
    fi
  else
    echo
    echo "New file:                 : $NEW_FILE"
    echo "No corresponding old file : $OLD_FILE"

    echo "next [y\N]? "
    read -n 1 -s input
    if [ "$input" == "N" ]; then exit 0; fi
  fi
done

OLDFILES=$(find $OLD_PATH -name '*.html.raw')
for OLD_FILE in $OLDFILES
do
  NEW_FILE=${OLD_FILE/$OLD_PATH/$NEW_PATH}
  if [ ! -f $NEW_FILE ]
  then
    echo
    echo "Old file:                 : $OLD_FILE"
    echo "No corresponding new file : $NEW_FILE"
  fi
done