From 20e5f3a1480b83b7977e6354a3ee133974067846 Mon Sep 17 00:00:00 2001 From: Michael Kohlhase Date: Wed, 16 Nov 2016 12:04:25 +0100 Subject: [PATCH] to (eventually; see #25) automate the gitinfo2 hooks --- lib/gitinfo2-hook.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/gitinfo2-hook.sh diff --git a/lib/gitinfo2-hook.sh b/lib/gitinfo2-hook.sh new file mode 100644 index 0000000..d9e6ddb --- /dev/null +++ b/lib/gitinfo2-hook.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# Copyright 2015 Brent Longborough +# Part of gitinfo2 package Version 2 +# Release 2.0.7 2015-11-22 +# Please read gitinfo2.pdf for licencing and other details +# ----------------------------------------------------- +# Post-{commit,checkout,merge} hook for the gitinfo2 package +# +# Get the first tag found in the history from the current HEAD +FIRSTTAG=$(git describe --tags --always --dirty='-*' 2>/dev/null) +# Get the first tag in history that looks like a Release +RELTAG=$(git describe --tags --long --always --dirty='-*' --match '[0-9]*.*' 2>/dev/null) +# Hoover up the metadata +git --no-pager log -1 --date=short --decorate=short \ + --pretty=format:"\usepackage[% + shash={%h}, + lhash={%H}, + authname={%an}, + authemail={%ae}, + authsdate={%ad}, + authidate={%ai}, + authudate={%at}, + commname={%cn}, + commemail={%ce}, + commsdate={%cd}, + commidate={%ci}, + commudate={%ct}, + refnames={%d}, + firsttagdescribe={$FIRSTTAG}, + reltag={$RELTAG} + ]{gitexinfo}" HEAD > .git/gitHeadInfo.gin