[java-sig-commits] [javapackages] fixed: pom_xpath_inject macro should fail if provided XML code is not valid XML

Michael Šimáček msimacek at fedoraproject.org
Wed Sep 18 11:37:02 UTC 2013


commit aabfd56144f4109e1969272cbb56f722e8613845
Author: Michael Simacek <msimacek at redhat.com>
Date:   Wed Sep 18 13:35:22 2013 +0200

    fixed: pom_xpath_inject macro should fail if provided XML code is not valid XML

 TODO                     |    4 ----
 java-utils/pom_editor.sh |    7 +++++--
 2 files changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/TODO b/TODO
index 8f18f4c..c0b25be 100644
--- a/TODO
+++ b/TODO
@@ -17,10 +17,6 @@
 
 ** Fix version in python/setup.py
 
-** pom_xpath_inject macro should fail if provided XML code is not valid XML
-
-   Currently the macro adds only "code added by maintainer" comments, nothing else.
-
 * FEATURES
 
 ** %mvn_config support for XML contents
diff --git a/java-utils/pom_editor.sh b/java-utils/pom_editor.sh
index 26be1d7..bd090d1 100644
--- a/java-utils/pom_editor.sh
+++ b/java-utils/pom_editor.sh
@@ -159,7 +159,8 @@ EOF
 EOF
 )|tail -n +3| head -n -1| sed "s/^  //" |sed -e "s/  /${tab}/g"|sed -e "s/^\s\+$//"
 )
-   rm -f .input
+   rm -f .input.xml
+   test -n "${injected}"|| _pom_bailout Injected XML is not well-formed
    sed -e  "s|\(\s*\)\(.*\)|<xsl:text>\n${indent}\1${tab}</xsl:text>\2|" <<EOF
 <xsl:comment> begin of code added by maintainer </xsl:comment>
 ${injected}
@@ -174,6 +175,7 @@ EOF
 _pom_replace_xpath()
 {
     local code=$(_pom_reformat_injected "${1}" "${2}" "${3}") 
+    test -n "${code}" || exit 1
     _pom_patch "${1}" <<EOF
 ${_pom_xslt_header}
   <xsl:template match="${2}">
@@ -207,7 +209,8 @@ EOF
 #  $3 - code to inject
 _pom_inject_xpath()
 {
-    local code=$(_pom_reformat_injected "${1}" "${2}" "${3}") 
+    local code=$(_pom_reformat_injected "${1}" "${2}" "${3}")
+    test -n "${code}" || exit 1
     _pom_patch "${1}" <<EOF
 ${_pom_xslt_header}
   <xsl:template match="${2}">


More information about the java-sig-commits mailing list