#!/bin/bash

export OUT_FILE=commit.tex

if [ "$1" == "release" ]; then
  echo "Document version: `head -n 1 debian/changelog | sed -r 's/([^\)]+)\(([0-9.]+)\)([^$]+)/\2/'`" > $OUT_FILE;
elif [ -d .git ]; then
  echo "Document revision: `git log --format='format:%H %ad' --date=short | head -n 1`" > $OUT_FILE;
else
  echo "Document version: `head -n 1 debian/changelog | sed -r 's/([^\)]+)\(([0-9.]+)\)([^$]+)/\2/'`" > $OUT_FILE;
fi
