From 94b34ea031aef4305b9effb7a13bf1b063a2b5fe Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Mon, 17 Jan 2011 23:00:20 -0800 Subject: [PATCH] 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.) --- Documentation/default.1.do | 2 +- Documentation/default.md.tmp.do | 3 +++ Documentation/md-to-man.do | 2 +- Documentation/redo-always.md | 4 ++-- Documentation/redo-ifchange.md | 4 ++-- Documentation/redo-ifcreate.md | 4 ++-- Documentation/redo-ood.md | 4 ++-- Documentation/redo-sources.md | 4 ++-- Documentation/redo-stamp.md | 4 ++-- Documentation/redo-targets.md | 4 ++-- Documentation/redo.md | 4 ++-- _all.do | 2 +- clean.do | 2 +- version/.gitattributes | 1 + version/.gitignore | 3 +++ version/__init__.py | 1 + version/_version.py.do | 3 +++ version/all.do | 2 ++ version/clean.do | 3 +++ version/gitvars.do | 24 ++++++++++++++++++++ version/gitvars.pre | 3 +++ version/prodname | 1 + version/vars.do | 40 +++++++++++++++++++++++++++++++++ 23 files changed, 104 insertions(+), 20 deletions(-) create mode 100644 Documentation/default.md.tmp.do create mode 100644 version/.gitattributes create mode 100644 version/.gitignore create mode 100644 version/__init__.py create mode 100644 version/_version.py.do create mode 100644 version/all.do create mode 100644 version/clean.do create mode 100644 version/gitvars.do create mode 100644 version/gitvars.pre create mode 100644 version/prodname create mode 100644 version/vars.do diff --git a/Documentation/default.1.do b/Documentation/default.1.do index 26594b8..1d66fb4 100644 --- a/Documentation/default.1.do +++ b/Documentation/default.1.do @@ -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 diff --git a/Documentation/default.md.tmp.do b/Documentation/default.md.tmp.do new file mode 100644 index 0000000..cc0ca4b --- /dev/null +++ b/Documentation/default.md.tmp.do @@ -0,0 +1,3 @@ +redo-ifchange ../version/vars $1.md +. ../version/vars +sed -e "s/%VERSION%/$TAG/" -e "s/%DATE%/$DATE/" $1.md diff --git a/Documentation/md-to-man.do b/Documentation/md-to-man.do index 4ae53e7..d678313 100644 --- a/Documentation/md-to-man.do +++ b/Documentation/md-to-man.do @@ -1,5 +1,5 @@ if pandoc /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 (IFS=:; for DIR in $PATH; do redo-ifcreate "$DIR/pandoc"; done) echo "Warning: pandoc not installed; can't generate manpages." >&2 diff --git a/Documentation/redo-always.md b/Documentation/redo-always.md index 47e13cc..a48da69 100644 --- a/Documentation/redo-always.md +++ b/Documentation/redo-always.md @@ -1,6 +1,6 @@ -% redo-always(1) Redo 0.00 +% redo-always(1) Redo %VERSION% % Avery Pennarun -% 2010-12-12 +% %DATE% # NAME diff --git a/Documentation/redo-ifchange.md b/Documentation/redo-ifchange.md index 7c4a71f..9405d73 100644 --- a/Documentation/redo-ifchange.md +++ b/Documentation/redo-ifchange.md @@ -1,6 +1,6 @@ -% redo-ifchange(1) Redo 0.00 +% redo-ifchange(1) Redo %VERSION% % Avery Pennarun -% 2010-12-12 +% %DATE% # NAME diff --git a/Documentation/redo-ifcreate.md b/Documentation/redo-ifcreate.md index 4a91672..12afd16 100644 --- a/Documentation/redo-ifcreate.md +++ b/Documentation/redo-ifcreate.md @@ -1,6 +1,6 @@ -% redo-ifcreate(1) Redo 0.00 +% redo-ifcreate(1) Redo %VERSION% % Avery Pennarun -% 2010-12-12 +% %DATE% # NAME diff --git a/Documentation/redo-ood.md b/Documentation/redo-ood.md index 3719920..823f651 100644 --- a/Documentation/redo-ood.md +++ b/Documentation/redo-ood.md @@ -1,6 +1,6 @@ -% redo-ood(1) Redo 0.00 +% redo-ood(1) Redo %VERSION% % Avery Pennarun -% 2010-12-19 +% %DATE% # NAME diff --git a/Documentation/redo-sources.md b/Documentation/redo-sources.md index 1023ea6..d6c3fe4 100644 --- a/Documentation/redo-sources.md +++ b/Documentation/redo-sources.md @@ -1,6 +1,6 @@ -% redo-sources(1) Redo 0.00 +% redo-sources(1) Redo %VERSION% % Avery Pennarun -% 2010-12-19 +% %DATE% # NAME diff --git a/Documentation/redo-stamp.md b/Documentation/redo-stamp.md index c965ad7..2cf7bc8 100644 --- a/Documentation/redo-stamp.md +++ b/Documentation/redo-stamp.md @@ -1,6 +1,6 @@ -% redo-stamp(1) Redo 0.00 +% redo-stamp(1) Redo %VERSION% % Avery Pennarun -% 2010-12-12 +% %DATE% # NAME diff --git a/Documentation/redo-targets.md b/Documentation/redo-targets.md index 4892a5a..e1af075 100644 --- a/Documentation/redo-targets.md +++ b/Documentation/redo-targets.md @@ -1,6 +1,6 @@ -% redo-targets(1) Redo 0.00 +% redo-targets(1) Redo %VERSION% % Avery Pennarun -% 2010-12-19 +% %DATE% # NAME diff --git a/Documentation/redo.md b/Documentation/redo.md index 2cbf201..2250249 100644 --- a/Documentation/redo.md +++ b/Documentation/redo.md @@ -1,6 +1,6 @@ -% redo(1) Redo 0.00 +% redo(1) Redo %VERSION% % Avery Pennarun -% 2010-12-12 +% %DATE% # NAME diff --git a/_all.do b/_all.do index 6623acb..f1d9513 100644 --- a/_all.do +++ b/_all.do @@ -1,2 +1,2 @@ redo-ifchange redo-sh -redo-ifchange Documentation/all +redo-ifchange version/all Documentation/all diff --git a/clean.do b/clean.do index 938703b..16df2c3 100644 --- a/clean.do +++ b/clean.do @@ -5,6 +5,6 @@ if [ -e .do_built ]; then done <.do_built fi [ -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 find . -name '*.tmp' -exec rm -fv {} \; diff --git a/version/.gitattributes b/version/.gitattributes new file mode 100644 index 0000000..1dbc5f8 --- /dev/null +++ b/version/.gitattributes @@ -0,0 +1 @@ +gitvars.pre export-subst diff --git a/version/.gitignore b/version/.gitignore new file mode 100644 index 0000000..dccdd45 --- /dev/null +++ b/version/.gitignore @@ -0,0 +1,3 @@ +/vars +/gitvars +/_version.py diff --git a/version/__init__.py b/version/__init__.py new file mode 100644 index 0000000..2863a1d --- /dev/null +++ b/version/__init__.py @@ -0,0 +1 @@ +from _version import COMMIT, TAG, DATE diff --git a/version/_version.py.do b/version/_version.py.do new file mode 100644 index 0000000..cc22aad --- /dev/null +++ b/version/_version.py.do @@ -0,0 +1,3 @@ +redo-ifchange vars +cat vars + diff --git a/version/all.do b/version/all.do new file mode 100644 index 0000000..db6567c --- /dev/null +++ b/version/all.do @@ -0,0 +1,2 @@ +redo-ifchange vars _version.py + diff --git a/version/clean.do b/version/clean.do new file mode 100644 index 0000000..16f3859 --- /dev/null +++ b/version/clean.do @@ -0,0 +1,3 @@ +rm -f *~ .*~ *.pyc _version.py vars gitvars + + diff --git a/version/gitvars.do b/version/gitvars.do new file mode 100644 index 0000000..0f2e698 --- /dev/null +++ b/version/gitvars.do @@ -0,0 +1,24 @@ +redo-ifchange gitvars.pre prodname + +read PROD