catch asciidoc failures
PATCH 1/1 catch asciidoc failures
If pipefail is available (GNU bash >= 3.00), fail when asciidoc returns error rather than possibly later during XSLT.
---
This is my first git patch, so please let me know if I got the procedure wrong.
Documentation/Makefile | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
Documentation/Makefile +2 -0
@@ -111,6 +111,7 @@ clean: %.html : %.txt rm -f $@+ $@ + set -o pipefail 2>/dev/null; \ $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \ $(ASCIIDOC_EXTRA) -o - $< | \ sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' >$@+
@@ -121,6 +122,7 @@ clean: %.xml : %.txt rm -f $@+ $@ + set -o pipefail 2>/dev/null; \ $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \ $(ASCIIDOC_EXTRA) -o - $< | \ sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' >$@+
Signature · 1 line
1.5.2
hoi :)
Quoted 2 lines · Scott Lamb
If pipefail is available (GNU bash >= 3.00), fail when asciidoc returns error rather than possibly later during XSLT.
perhaps we should simply change the pipe ordering to get asciidoc to the end of the pipeline so that all shells respect its exit code?
Documentation/Makefile clean: · line 117
Quoted 10 lines
Documentation/Makefile +1
-0@@ -111,6 +111,7 @@ clean: %.html : %.txt rm -f $@+ $@ + set -o pipefail 2>/dev/null; \ $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \ $(ASCIIDOC_EXTRA) -o - $< | \ sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' >$@+
something like (untested):
sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' $< | $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \ $(ASCIIDOC_EXTRA) -o $@+ -
Signature · 1 line
Martin Waitz
Quoted 7 lines · Martin Waitz
perhaps we should simply change the pipe ordering to get asciidoc to the end of the pipeline so that all shells respect its exit code? [...]
something like (untested):sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' $< | $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \ $(ASCIIDOC_EXTRA) -o $@+ -
That won't work. The text @@GIT_VERSION@@ is pulled in from the asciidoc.conf file, so it's not even in the source file; it's only in the built product.
As Jonas suggested, making it an asciidoc attribute is much more elegant (patch even tested!):
-- >8 --
Documentation: robustify asciidoc GIT_VERSION replacement
Instead of using sed on the resulting file, we now have a git_version asciidoc attribute. This means that we don't pipe the output of asciidoc, which means we can detect build failures.
Problem reported by Scott Lamb, solution suggested by Jonas Fonseca.
--- Documentation/Makefile | 6 ++---- Documentation/asciidoc.conf | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-)
Documentation/Makefile +2 -4
@@ -112,8 +112,7 @@ clean: %.html : %.txt rm -f $@+ $@ $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \ - $(ASCIIDOC_EXTRA) -o - $< | \ - sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' >$@+ + $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< mv $@+ $@ %.1 %.5 %.7 : %.xml
@@ -122,8 +121,7 @@ clean: %.xml : %.txt rm -f $@+ $@ $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \ - $(ASCIIDOC_EXTRA) -o - $< | \ - sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' >$@+ + $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< mv $@+ $@ user-manual.xml: user-manual.txt user-manual.conf
Documentation/asciidoc.conf +1 -1
@@ -40,7 +40,7 @@ template::[header-declarations] <refentrytitle>{mantitle}</refentrytitle> <manvolnum>{manvolnum}</manvolnum> <refmiscinfo class="source">Git</refmiscinfo> -<refmiscinfo class="version">@@GIT_VERSION@@</refmiscinfo> +<refmiscinfo class="version">{git_version}</refmiscinfo> <refmiscinfo class="manual">Git Manual</refmiscinfo> </refmeta> <refnamediv>
Signature · 1 line
1.5.2.871.g0ff23
hoi :)
Quoted 2 lines · Jeff King
As Jonas suggested, making it an asciidoc attribute is much more elegant (patch even tested!):
very nice!
Does that need any special asciidoc version?
Signature · 1 line
Martin Waitz
Quoted 2 lines · Martin Waitz
very nice!
Does that need any special asciidoc version?
I don't think so, but I'm not an asciidoc expert. Flipping through the changelog, it looks like '-a' has existed since before 7.0.
-Peff
Documentation/Makefile clean: · line 116
Quoted 7 lines · Jeff King
%.html : %.txt
Documentation/Makefile +1
-2rm -f $@+ $@ $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \ - $(ASCIIDOC_EXTRA) -o - $< | \ - sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' >$@+ + $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< mv $@+ $@
Hmm, now the $@+ intermediary shouldn't be necessary anymore - with "-o" it's asciidoc's responsibility to handle the output file correctly.
I think there's a lightbulb joke here somewhere. ;)
Signature · 1 line
Scott Lamb <http://www.slamb.org/>
Quoted 6 lines · Martin Waitz
Quoted 2 lines · Scott Lamb
If pipefail is available (GNU bash >= 3.00), fail when asciidoc returns error rather than possibly later during XSLT.
perhaps we should simply change the pipe ordering to get asciidoc to the end of the pipeline so that all shells respect its exit code?
For tig I also adopted the nice man page headers git has. However, I have used asciidoc attributes provided on the command line avoid having to use sed. I can make a patch later if nobody beats me. The required changes are outlined below.
Quoted 12 lines
Documentation/Makefile clean: · line 117
Quoted 10 lines
Documentation/Makefile +1
-0@@ -111,6 +111,7 @@ clean: %.html : %.txt rm -f $@+ $@ + set -o pipefail 2>/dev/null; \ $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \ $(ASCIIDOC_EXTRA) -o - $< | \ sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' >$@+something like (untested):
Quoted 3 lines
sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' $< |
$(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
$(ASCIIDOC_EXTRA) -o $@+ -More untested stuff. Use -a to define git_version attribute:
$(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
$(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@ $<Then change the @@GIT_VERSION@@ symbol in asciidoc.conf to {git_version}.
Signature · 1 line
Jonas Fonseca