This is an automated email from the ASF dual-hosted git repository. royteeuwen pushed a commit to branch feature/SLING-13253-finalize-site-update in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-committer-cli.git
commit eaa5dc590b57aee4351c61306ad2267bf61946b1 Author: Roy Teeuwen <[email protected]> AuthorDate: Tue Aug 4 20:23:15 2026 +0200 SLING-13253 - update-local-site: drop the superseded name-based matching The display-name based updateDownloads had no callers left once downloads.tpl entries are matched on the artifact id, which also covers the --release path because the artifact ids are then read from the released POMs in dist/release. Its tests are replaced by artifact-id equivalents. --- .../sling/cli/impl/jbake/JBakeContentUpdater.java | 32 -------------------- .../cli/impl/jbake/JBakeContentUpdaterTest.java | 35 ++++------------------ 2 files changed, 6 insertions(+), 61 deletions(-) diff --git a/src/main/java/org/apache/sling/cli/impl/jbake/JBakeContentUpdater.java b/src/main/java/org/apache/sling/cli/impl/jbake/JBakeContentUpdater.java index 78db324..9f51ce0 100644 --- a/src/main/java/org/apache/sling/cli/impl/jbake/JBakeContentUpdater.java +++ b/src/main/java/org/apache/sling/cli/impl/jbake/JBakeContentUpdater.java @@ -26,49 +26,17 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Locale; -import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; public class JBakeContentUpdater { - private static final Pattern DOWNLOAD_LINE_PATTERN = - Pattern.compile("^.*\"([a-zA-Z\\s\\-]+)\\|([a-zA-Z\\.\\-]+)\\|([0-9\\.\\-]+).*$"); - /** * A version column: starts with a digit and contains only version characters. Deliberately does not * match a Groovy interpolation such as {@code ${starterVersion}}, which must never be rewritten. */ private static final Pattern VERSION_COLUMN = Pattern.compile("^[0-9][0-9A-Za-z.\\-]*$"); - public int updateDownloads(Path downloadsTemplatePath, String newReleaseName, String newReleaseVersion) - throws IOException { - - int[] changeCount = new int[1]; - - List<String> updatedLines = Files.readAllLines(downloadsTemplatePath, StandardCharsets.UTF_8).stream() - .map(line -> { - Matcher matcher = DOWNLOAD_LINE_PATTERN.matcher(line); - if (!matcher.find()) return line; - - if (!matcher.group(1).equals(newReleaseName)) return line; - - changeCount[0]++; - - StringBuilder buffer = new StringBuilder(); - buffer.append(line.substring(0, matcher.start(3))); - buffer.append(newReleaseVersion); - buffer.append(line.substring(matcher.end(3))); - - return buffer.toString(); - }) - .collect(Collectors.toList()); - - Files.write(downloadsTemplatePath, updatedLines); - - return changeCount[0]; - } - /** * Updates the version of every {@code downloads.tpl} entry that declares {@code artifactId}. * diff --git a/src/test/java/org/apache/sling/cli/impl/jbake/JBakeContentUpdaterTest.java b/src/test/java/org/apache/sling/cli/impl/jbake/JBakeContentUpdaterTest.java index 936b185..e1bb624 100644 --- a/src/test/java/org/apache/sling/cli/impl/jbake/JBakeContentUpdaterTest.java +++ b/src/test/java/org/apache/sling/cli/impl/jbake/JBakeContentUpdaterTest.java @@ -29,7 +29,6 @@ import java.time.LocalDateTime; import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.Optional; import java.util.stream.Collectors; import org.eclipse.jgit.api.Git; @@ -218,35 +217,13 @@ public class JBakeContentUpdaterTest { } @Test - public void updateDownloadsTemplate_newReleaseOfExistingModule() throws IOException { - - updateDownloadsTemplate0("API", "2.20.2"); - } - - private void updateDownloadsTemplate0(String newReleaseName, String newReleaseVersion) throws IOException { - Path templatePath = Paths.get(new File(tmp.getRoot(), "downloads.tpl").toURI()); - - int changeCount = updater.updateDownloads(templatePath, newReleaseName, newReleaseVersion); - assertThat("Unexpected count of changes", changeCount, equalTo(1)); - - Optional<String> apiLineHolder = Files.readAllLines(templatePath, StandardCharsets.UTF_8).stream() - .filter(l -> l.trim().startsWith("\"" + newReleaseName + "|")) - .findFirst(); - assertTrue(apiLineHolder.isPresent()); - String apiLine = apiLineHolder.get(); - assertThat("Did not find modified version in the release line", apiLine, containsString(newReleaseVersion)); - } - - @Test - public void updateDownloadsTemplate_newReleaseOfExistingMavenPlugin() throws IOException { - - updateDownloadsTemplate0("Slingstart Maven Plugin", "1.9.0"); - } - - @Test - public void updateDownloadsTemplate_newReleaseOfIDETooling() throws IOException { + public void updateDownloadsByArtifactId_updatesMavenPluginEntry() throws IOException { + // maven plugin entries carry a bare artifact id rather than a fully qualified one + JBakeContentUpdater.DownloadsUpdate result = + updater.updateDownloadsByArtifactId(templatePath(), "slingstart-maven-plugin", "1.9.0"); - updateDownloadsTemplate0("Sling IDE Tooling for Eclipse", "1.4.0"); + assertThat(result.updated(), equalTo(1)); + assertThat(lineFor("slingstart-maven-plugin"), containsString("|1.9.0|")); } @Test
