Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.)
  • Loading branch information...
commit 94b34ea031aef4305b9effb7a13bf1b063a2b5fe 1 parent 897c218
@apenwarr authored
View
2  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
View
3  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
View
2  Documentation/md-to-man.do
@@ -1,5 +1,5 @@
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
(IFS=:; for DIR in $PATH; do redo-ifcreate "$DIR/pandoc"; done)
echo "Warning: pandoc not installed; can't generate manpages." >&2
View
4 Documentation/redo-always.md
@@ -1,6 +1,6 @@
-% redo-always(1) Redo 0.00
+% redo-always(1) Redo %VERSION%
% Avery Pennarun <apenwarr@gmail.com>
-% 2010-12-12
+% %DATE%
# NAME
View
4 Documentation/redo-ifchange.md
@@ -1,6 +1,6 @@
-% redo-ifchange(1) Redo 0.00
+% redo-ifchange(1) Redo %VERSION%
% Avery Pennarun <apenwarr@gmail.com>
-% 2010-12-12
+% %DATE%
# NAME
View
4 Documentation/redo-ifcreate.md
@@ -1,6 +1,6 @@
-% redo-ifcreate(1) Redo 0.00
+% redo-ifcreate(1) Redo %VERSION%
% Avery Pennarun <apenwarr@gmail.com>
-% 2010-12-12
+% %DATE%
# NAME
View
4 Documentation/redo-ood.md
@@ -1,6 +1,6 @@
-% redo-ood(1) Redo 0.00
+% redo-ood(1) Redo %VERSION%
% Avery Pennarun <apenwarr@gmail.com>
-% 2010-12-19
+% %DATE%
# NAME
View
4 Documentation/redo-sources.md
@@ -1,6 +1,6 @@
-% redo-sources(1) Redo 0.00
+% redo-sources(1) Redo %VERSION%
% Avery Pennarun <apenwarr@gmail.com>
-% 2010-12-19
+% %DATE%
# NAME
View
4 Documentation/redo-stamp.md
@@ -1,6 +1,6 @@
-% redo-stamp(1) Redo 0.00
+% redo-stamp(1) Redo %VERSION%
% Avery Pennarun <apenwarr@gmail.com>
-% 2010-12-12
+% %DATE%
# NAME
View
4 Documentation/redo-targets.md
@@ -1,6 +1,6 @@
-% redo-targets(1) Redo 0.00
+% redo-targets(1) Redo %VERSION%
% Avery Pennarun <apenwarr@gmail.com>
-% 2010-12-19
+% %DATE%
# NAME
View
4 Documentation/redo.md
@@ -1,6 +1,6 @@
-% redo(1) Redo 0.00
+% redo(1) Redo %VERSION%
% Avery Pennarun <apenwarr@gmail.com>
-% 2010-12-12
+% %DATE%
# NAME
View
2  _all.do
@@ -1,2 +1,2 @@
redo-ifchange redo-sh
-redo-ifchange Documentation/all
+redo-ifchange version/all Documentation/all
View
2  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 {} \;
View
1  version/.gitattributes
@@ -0,0 +1 @@
+gitvars.pre export-subst
View
3  version/.gitignore
@@ -0,0 +1,3 @@
+/vars
+/gitvars
+/_version.py
View
1  version/__init__.py
@@ -0,0 +1 @@
+from _version import COMMIT, TAG, DATE
View
3  version/_version.py.do
@@ -0,0 +1,3 @@
+redo-ifchange vars
+cat vars
+
View
2  version/all.do
@@ -0,0 +1,2 @@
+redo-ifchange vars _version.py
+
View
3  version/clean.do
@@ -0,0 +1,3 @@
+rm -f *~ .*~ *.pyc _version.py vars gitvars
+
+
View
24 version/gitvars.do
@@ -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
View
3  version/gitvars.pre
@@ -0,0 +1,3 @@
+$Format:%H$
+$Format:%d$
+$Format:%ci$
View
1  version/prodname
@@ -0,0 +1 @@
+redo
View
40 version/vars.do
@@ -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%% *}'"
Please sign in to comment.
Something went wrong with that request. Please try again.