diff --git a/.circleci/config.yml b/.circleci/config.yml
index 7ad4530..f0ab6c6 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -18,11 +18,8 @@ jobs:
name: Copy deploy script to workspace
command: cp ./deploy.sh /tmp/workspace/deploy.sh
- run:
- name: Get latexdiff
- command: git clone https://github.com/ftilmann/latexdiff && echo | cpan && cpan Algorithm::Diff && ./latexdiff/latexdiff-vc --git -r master main.tex
- - run:
- name: Build whitepaper diff
- command: pdflatex main-diffmaster.tex && bibtex main-diffmaster && pdflatex main-diffmaster.tex && pdflatex main-diffmaster.tex
+ name: Run latexdiff
+ command: bash ./latexdiff-wrapper.sh main.tex master
- persist_to_workspace:
root: /tmp/workspace
paths:
@@ -32,7 +29,7 @@ jobs:
path: ./main.pdf
destination: whitepaper.pdf
- store_artifacts:
- path: ./main-diffmaster.pdf
+ path: ./diff/main.pdf
destination: whitepaper-diff.pdf
deploy-job:
diff --git a/latexdiff-wrapper.sh b/latexdiff-wrapper.sh
new file mode 100644
index 0000000..013175e
--- /dev/null
+++ b/latexdiff-wrapper.sh
@@ -0,0 +1,91 @@
+#!/bin/sh
+# This script was made because latexdiff-vc was acting up
+# and not handling bibliographies satisfactorily.
+# Taken from https://github.com/ftilmann/latexdiff/pull/127
+
+help () {
+ echo "Usage: $0 [-d|--dir
]" \
+ "[.tex] [ []]"
+}
+
+# default options
+dest="diff"
+file=""
+a="HEAD"
+b=""
+
+# parse options
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -d|--dir) dest="$2"; shift 2 ;;
+ -h|-\?|--help) help; exit 0 ;;
+ --) shift; break ;;
+ -*) echo "Unknown option $1" >&2; help>&2; exit 1 ;;
+ *) break;;
+ esac
+done
+
+if [ $# -lt 1 -o $# -gt 3 ]; then
+ echo "Wrong number of arguments" >&2; help>&2; exit 1
+fi
+
+[ $# -ge 1 ] && file="$1"
+[ $# -ge 2 ] && a="$2"
+[ $# -ge 3 ] && b="$3"
+
+# fetch paths
+temp="$(mktemp -d)"
+proj="$(git rev-parse --show-toplevel)"
+path="$(git rev-parse --show-prefix)"
+
+# sanitize values
+temp="$(realpath "$temp")"
+proj="$(realpath "$proj")"
+dest="$(realpath "$dest")"
+file="${file%.tex}"
+
+# clone repositories
+cd "$proj"
+
+mkdir -p "$temp/a"
+if [ -n "$a" ]; then
+ git archive --format=tar "$a" | tar xf - -C "$temp/a"
+else
+ git ls-files -z | xargs -0 tar cf - | tar xf - -C "$temp/a"
+fi
+
+mkdir -p "$temp/b"
+if [ -n "$b" ]; then
+ git archive --format=tar "$b" | tar xf - -C "$temp/b"
+else
+ git ls-files -z | xargs -0 tar cf - | tar xf - -C "$temp/b"
+fi
+
+# generate .bbl (optional?)
+if true; then
+ cd "$temp/a/$path"
+ pdflatex "$file" -draftmode
+ bibtex "$file"
+
+ cd "$temp/b/$path"
+ pdflatex "$file" -draftmode
+ bibtex "$file"
+fi
+
+# run latexdiff
+mkdir -p "$dest"
+latexdiff --flatten "$temp/a/$path/$file.tex" "$temp/b/$path/$file.tex" \
+ > "$dest/$file.tex"
+
+# combine all old files and new files (added/removed figures, etc)
+cp -anT "$temp/a" "$temp/b"
+
+# compile LaTeX, with access to other files
+cd "$temp/b/$path"
+pdflatex -output-directory="$dest" "$dest/$file" -draftmode # 1
+pdflatex -output-directory="$dest" "$dest/$file" -draftmode # 2 (line numbers)
+pdflatex -output-directory="$dest" "$dest/$file" # 3
+
+# cleanup
+rm -Rf "$temp"
+