Generate redo version codes in Documentation/*.1 automatically.

We have to go through some pretty scary gyrations to extract this
information from git, but it can be done.  This works with both tarballs
generated by 'git archive', or with your local git repo.

(Requested by 'David' on the mailing list.)
This commit is contained in:
Avery Pennarun 2011-01-17 23:00:20 -08:00
commit 94b34ea031
23 changed files with 104 additions and 20 deletions

24
version/gitvars.do Normal file
View file

@ -0,0 +1,24 @@
redo-ifchange gitvars.pre prodname
read PROD <prodname
# Fix each line from gitvars.pre where git may or may not have already
# substituted the variables. If someone generated a tarball with 'git archive',
# then the data will have been substituted already. If we're in a checkout of
# the git repo, then it won't, but we can just ask git to do the substitutions
# right now.
while read line; do
# Lines *may* be of the form: $Format: ... $
x=${line#\$Format:} # remove prefix
if [ "$x" != "$line" ]; then
# git didn't substitute it
x=${x%\$} # remove trailing $
if [ "$x" == "%d" ]; then
tag=$(git describe --match="$PROD-*")
x="(tag: $tag)"
else
x=$(git log -1 --pretty=format:"$x")
fi
fi
echo "$x"
done <gitvars.pre