This is an automated email from the ASF dual-hosted git repository. bdelacretaz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-site.git
commit 868f48f639351369928d00d2cd2c8aba3642d57a Author: Bertrand Delacretaz <[email protected]> AuthorDate: Mon Apr 27 10:12:24 2020 +0200 Better reporting of incorrectly formatted data lines --- src/main/jbake/templates/downloads.tpl | 14 ++++++++------ src/main/jbake/templates/includes/U.groovy | 13 +++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/main/jbake/templates/downloads.tpl b/src/main/jbake/templates/downloads.tpl index f7ffb2a..ebf802d 100644 --- a/src/main/jbake/templates/downloads.tpl +++ b/src/main/jbake/templates/downloads.tpl @@ -12,6 +12,8 @@ // To convert from the old svn downloads.list ust // while read l; do echo " \"$l\","; done < content/downloads.list // ------------------------------------------------------------------------------------------------ +U = new includes.U(config) +def PIPE_SEP = "\\|" def launchpadVersion="11" def slingIDETooling=[ @@ -366,7 +368,7 @@ layout 'layout/main.tpl', true, tbody() { slingApplication.each { line -> tr() { - def data = line.split("\\|") + def data = U.splitLine(line, PIPE_SEP, 6) td(data[0]) td(data[4]) td(){ @@ -388,7 +390,7 @@ layout 'layout/main.tpl', true, tbody() { slingIDETooling.each { line -> tr() { - def data = line.split("\\|") + def data = U.splitLine(line, PIPE_SEP, 3) td(data[0]) td(data[2]) td(data[3]) @@ -407,7 +409,7 @@ layout 'layout/main.tpl', true, tbody() { bundles.each { line -> tr() { - def data = line.split("\\|") + def data = U.splitLine(line, PIPE_SEP, 5) td(data[0]) td(data[2]) def artifact = data[1] @@ -434,7 +436,7 @@ layout 'layout/main.tpl', true, tbody() { mavenPlugins.each { line -> tr() { - def data = line.split("\\|") + def data = U.splitLine(line, PIPE_SEP, 4) td(data[0]) td(data[2]) def artifact = data[1] @@ -460,7 +462,7 @@ layout 'layout/main.tpl', true, tbody() { bndPlugins.each { line -> tr() { - def data = line.split("\\|") + def data = U.splitLine(line, PIPE_SEP, 4) td(data[0]) td(data[2]) def artifact = data[1] @@ -486,7 +488,7 @@ layout 'layout/main.tpl', true, tbody() { deprecated.each { line -> tr() { - def data = line.split("\\|") + def data = U.splitLine(line, PIPE_SEP, 4) td(data[0]) td(data[1]) td(data[3]) diff --git a/src/main/jbake/templates/includes/U.groovy b/src/main/jbake/templates/includes/U.groovy index bce03c6..9a12901 100644 --- a/src/main/jbake/templates/includes/U.groovy +++ b/src/main/jbake/templates/includes/U.groovy @@ -9,6 +9,19 @@ class U { def once = new runonce.OncePerBuild(jbakeConfig) } + def splitLine(line, separator, expectedParts) { + def result = line.split(separator) + if(result.length < expectedParts) { + throw new Exception( + "Expected " + expectedParts + + " parts separated with " + separator + + ", but got " + result.length + + " in line: " + line + ) + } + return result + } + def processBody(content, config) { def str = content.body
