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:
parent
897c218f85
commit
94b34ea031
23 changed files with 104 additions and 20 deletions
|
|
@ -1,2 +1,2 @@
|
||||||
redo-ifchange md-to-man $1.md
|
redo-ifchange md-to-man $1.md.tmp
|
||||||
. ./md-to-man $1 $2 $3
|
. ./md-to-man $1 $2 $3
|
||||||
|
|
|
||||||
3
Documentation/default.md.tmp.do
Normal file
3
Documentation/default.md.tmp.do
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
redo-ifchange ../version/vars $1.md
|
||||||
|
. ../version/vars
|
||||||
|
sed -e "s/%VERSION%/$TAG/" -e "s/%DATE%/$DATE/" $1.md
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
if pandoc </dev/null 2>/dev/null; then
|
if pandoc </dev/null 2>/dev/null; then
|
||||||
echo 'pandoc -s -r markdown -w man -o $3 $1.md'
|
echo 'pandoc -s -r markdown -w man -o $3 $1.md.tmp'
|
||||||
else
|
else
|
||||||
(IFS=:; for DIR in $PATH; do redo-ifcreate "$DIR/pandoc"; done)
|
(IFS=:; for DIR in $PATH; do redo-ifcreate "$DIR/pandoc"; done)
|
||||||
echo "Warning: pandoc not installed; can't generate manpages." >&2
|
echo "Warning: pandoc not installed; can't generate manpages." >&2
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
% redo-always(1) Redo 0.00
|
% redo-always(1) Redo %VERSION%
|
||||||
% Avery Pennarun <apenwarr@gmail.com>
|
% Avery Pennarun <apenwarr@gmail.com>
|
||||||
% 2010-12-12
|
% %DATE%
|
||||||
|
|
||||||
# NAME
|
# NAME
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
% redo-ifchange(1) Redo 0.00
|
% redo-ifchange(1) Redo %VERSION%
|
||||||
% Avery Pennarun <apenwarr@gmail.com>
|
% Avery Pennarun <apenwarr@gmail.com>
|
||||||
% 2010-12-12
|
% %DATE%
|
||||||
|
|
||||||
# NAME
|
# NAME
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
% redo-ifcreate(1) Redo 0.00
|
% redo-ifcreate(1) Redo %VERSION%
|
||||||
% Avery Pennarun <apenwarr@gmail.com>
|
% Avery Pennarun <apenwarr@gmail.com>
|
||||||
% 2010-12-12
|
% %DATE%
|
||||||
|
|
||||||
# NAME
|
# NAME
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
% redo-ood(1) Redo 0.00
|
% redo-ood(1) Redo %VERSION%
|
||||||
% Avery Pennarun <apenwarr@gmail.com>
|
% Avery Pennarun <apenwarr@gmail.com>
|
||||||
% 2010-12-19
|
% %DATE%
|
||||||
|
|
||||||
# NAME
|
# NAME
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
% redo-sources(1) Redo 0.00
|
% redo-sources(1) Redo %VERSION%
|
||||||
% Avery Pennarun <apenwarr@gmail.com>
|
% Avery Pennarun <apenwarr@gmail.com>
|
||||||
% 2010-12-19
|
% %DATE%
|
||||||
|
|
||||||
# NAME
|
# NAME
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
% redo-stamp(1) Redo 0.00
|
% redo-stamp(1) Redo %VERSION%
|
||||||
% Avery Pennarun <apenwarr@gmail.com>
|
% Avery Pennarun <apenwarr@gmail.com>
|
||||||
% 2010-12-12
|
% %DATE%
|
||||||
|
|
||||||
# NAME
|
# NAME
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
% redo-targets(1) Redo 0.00
|
% redo-targets(1) Redo %VERSION%
|
||||||
% Avery Pennarun <apenwarr@gmail.com>
|
% Avery Pennarun <apenwarr@gmail.com>
|
||||||
% 2010-12-19
|
% %DATE%
|
||||||
|
|
||||||
# NAME
|
# NAME
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
% redo(1) Redo 0.00
|
% redo(1) Redo %VERSION%
|
||||||
% Avery Pennarun <apenwarr@gmail.com>
|
% Avery Pennarun <apenwarr@gmail.com>
|
||||||
% 2010-12-12
|
% %DATE%
|
||||||
|
|
||||||
# NAME
|
# NAME
|
||||||
|
|
||||||
|
|
|
||||||
2
_all.do
2
_all.do
|
|
@ -1,2 +1,2 @@
|
||||||
redo-ifchange redo-sh
|
redo-ifchange redo-sh
|
||||||
redo-ifchange Documentation/all
|
redo-ifchange version/all Documentation/all
|
||||||
|
|
|
||||||
2
clean.do
2
clean.do
|
|
@ -5,6 +5,6 @@ if [ -e .do_built ]; then
|
||||||
done <.do_built
|
done <.do_built
|
||||||
fi
|
fi
|
||||||
[ -z "$DO_BUILT" ] && rm -rf .do_built .do_built.dir
|
[ -z "$DO_BUILT" ] && rm -rf .do_built .do_built.dir
|
||||||
redo t/clean Documentation/clean
|
redo t/clean Documentation/clean version/clean
|
||||||
rm -f *~ .*~ */*~ */.*~ *.pyc install.wrapper
|
rm -f *~ .*~ */*~ */.*~ *.pyc install.wrapper
|
||||||
find . -name '*.tmp' -exec rm -fv {} \;
|
find . -name '*.tmp' -exec rm -fv {} \;
|
||||||
|
|
|
||||||
1
version/.gitattributes
vendored
Normal file
1
version/.gitattributes
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
gitvars.pre export-subst
|
||||||
3
version/.gitignore
vendored
Normal file
3
version/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
/vars
|
||||||
|
/gitvars
|
||||||
|
/_version.py
|
||||||
1
version/__init__.py
Normal file
1
version/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
from _version import COMMIT, TAG, DATE
|
||||||
3
version/_version.py.do
Normal file
3
version/_version.py.do
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
redo-ifchange vars
|
||||||
|
cat vars
|
||||||
|
|
||||||
2
version/all.do
Normal file
2
version/all.do
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
redo-ifchange vars _version.py
|
||||||
|
|
||||||
3
version/clean.do
Normal file
3
version/clean.do
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
rm -f *~ .*~ *.pyc _version.py vars gitvars
|
||||||
|
|
||||||
|
|
||||||
24
version/gitvars.do
Normal file
24
version/gitvars.do
Normal 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
|
||||||
3
version/gitvars.pre
Normal file
3
version/gitvars.pre
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
$Format:%H$
|
||||||
|
$Format:%d$
|
||||||
|
$Format:%ci$
|
||||||
1
version/prodname
Normal file
1
version/prodname
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
redo
|
||||||
40
version/vars.do
Normal file
40
version/vars.do
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
redo-ifchange gitvars prodname
|
||||||
|
|
||||||
|
read PROD <prodname
|
||||||
|
|
||||||
|
exec <gitvars
|
||||||
|
read COMMIT
|
||||||
|
read NAMES
|
||||||
|
read DATE
|
||||||
|
|
||||||
|
# the list of names is of the form:
|
||||||
|
# (x,y,tag: $PROD-####,tag: $PROD-####,a,b)
|
||||||
|
# The entries we want are the ones starting with "tag: $PROD-" since those
|
||||||
|
# refer to the right actual git tags.
|
||||||
|
names_to_tag()
|
||||||
|
{
|
||||||
|
x=${1#\(}
|
||||||
|
x=${x%\)}
|
||||||
|
cur=
|
||||||
|
while [ "$cur" != "$x" ]; do
|
||||||
|
cur=${x%%,*}
|
||||||
|
cur=${cur#tag: }
|
||||||
|
cur=${cur## }
|
||||||
|
tagpost=${cur#$PROD-}
|
||||||
|
if [ "$cur" != "$tagpost" ]; then
|
||||||
|
echo "$tagpost"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
x=${x#*,}
|
||||||
|
done
|
||||||
|
commitpost=${COMMIT#???????}
|
||||||
|
commitpre=${COMMIT%$commitpost}
|
||||||
|
echo "unknown-$commitpre"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sTAG=$(names_to_tag "$NAMES")
|
||||||
|
|
||||||
|
echo "COMMIT='$COMMIT'"
|
||||||
|
echo "TAG='$sTAG'"
|
||||||
|
echo "DATE='${DATE%% *}'"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue