Skip to content

Instantly share code, notes, and snippets.

@sss
Created June 17, 2012 18:11
Show Gist options
  • Save sss/2945246 to your computer and use it in GitHub Desktop.
Save sss/2945246 to your computer and use it in GitHub Desktop.
Updating metadata for gitinfo (in TeX Live)
[hooks.tex.gitinfo]
prefix = .
prefix = ./test
prefix = ./docs
#!/bin/sh
update-metadata-for-gitinfo

Tweaks for post-xxx-sample.txt in gitinfo (in TeX Live).

  • Can now specify target directories through git config. The key name is hooks.tex.gitinfo.prefix.
  • No need to modify update-metadata-for-gitinfo for each project.
  • Can now have spaces in target directory name.
#!/bin/sh
GITINFO_INDEX_FILENAME="gitHeadInfo.gin"
GITINFO_GIT_CONFIG="hooks.tex.gitinfo.prefix"
GITINFO_GIT_LOG_PRETTY_FORMAT=$(cat) <<'__EOS__'
\usepackage[%
shash={%h},
lhash={%H},
authname={%an},
authemail={%ae},
authsdate={%ad},
authidate={%ai},
authudate={%at},
commname={%an},
commemail={%ae},
commsdate={%ad},
commidate={%ai},
commudate={%at},
refnames={%d}
]{gitsetinfo}
__EOS__
git config --get-all "${GITINFO_GIT_CONFIG}" | \
(while read -r prefix; do
if [ -d "${prefix}" ]; then
git log -1 --date=short \
--pretty=format:"${GITINFO_GIT_LOG_PRETTY_FORMAT}" \
HEAD \
> "${prefix}/${GITINFO_INDEX_FILENAME}"
fi
done)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment