Skip to content
Snippets Groups Projects
Commit a30b335b authored by x2004933's avatar x2004933 :confused:
Browse files

Add diffs to pages

parent d5bbc8f1
No related branches found
No related tags found
No related merge requests found
*.html diff=pandoc
image: alpine
before_script:
- apk add git sed bash
- apk add git sed bash pandoc
pages_test:
stage: test
......
......@@ -7,7 +7,10 @@ pages_dir="public"
template="index.html"
links=""
mkdir "${pages_dir}"
mkdir -p "${pages_dir}"
# Set the diff tool
git config diff.pandoc.textconv 'pandoc -t gfm'
# Get the relevant commits from the log
commits=$(git log --pretty=oneline | grep "Update at" | cut -d' ' -f1)
......@@ -16,21 +19,32 @@ commits=$(git log --pretty=oneline | grep "Update at" | cut -d' ' -f1)
for c in $commits
do
# Checkout the relevant commit
git checkout "$c"
git checkout "$c" -- "${site_dir}"
# Get the date of the commit
date=$(git show -s --format=%ai "$c")
# Show the latest commit
git diff "$c~1" "$c" -- "${site_dir}" > "${pages_dir}/${c}.diff.txt"
# Check if commit is empty
if [[ -s "${pages_dir}/${c}.diff.txt" ]]
then
diff="<a href=\"${c}.diff.txt\">diff</a>"
else
diff="no changes"
fi
# Copy the state of the site to the pages dir
cp -a "${site_dir}" "${pages_dir}/${date}"
# Add a link to the index
links="${links}<li><a href=\"${date}/${main_dir}\">${date}</a></li>"
links="${links}<li><a href=\"${date}/${main_dir}\">${date}</a> (${diff})</li>"
# Create a 'latest' symlink for the latest commit
[ ! -e "${pages_dir}/latest" ] && ln -s "${date}" "${pages_dir}/latest"
done
git checkout master
git checkout master -- site/
# Create index file
sed "s|{{body}}|${links}|g" "${template}" > "${pages_dir}/index.html"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment