-
Notifications
You must be signed in to change notification settings - Fork 0
/
diff_reports.sh
executable file
·48 lines (40 loc) · 1.25 KB
/
diff_reports.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
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
for TEX in $( git diff --name-only $1 | grep tex )
do
#echo $TEX
[ -f "$TEX" ] || continue
tex='.tex'
fname=$(basename $TEX)
dirname=$(basename $(dirname $TEX))
apath=$(dirname $TEX)
# delete the working directory if it exists
# this is a bit fragile, but it only risks if
# directory contains a directory of content with the same
# dirname e.g. demo-project/demo-project/content
# which seems unlikely
if [ -d $apath/$dirname ]; then
echo 'deleting...'
rm -rf $apath/$dirname
fi
# only process the diff where name of controlling .tex file is
# the same as the name of the folder
if [ -f "$apath/$dirname$tex" ]; then
# only do this once per directory, even if multi-hits on .tex changes
if [ ! -d $apath/$dirname ]; then
# only create the diff if there is a version in the upstream
# (else latexdiff-git will error
if git show $1:$apath/$dirname$tex | cat ; then
mkdir $apath/$dirname
CWD=$(pwd)
cd $apath
echo $(pwd)
echo "latexdiff-git -r $1 --flatten -d $dirname $dirname$tex"
latexdiff-git -r $1 --flatten -d $dirname $dirname$tex
cd $CWD
echo $(pwd)
git add $apath/$dirname/$dirname$tex
fi
fi
fi
done
exit