royteeuwen commented on code in PR #32:
URL: 
https://github.com/apache/sling-org-apache-sling-committer-cli/pull/32#discussion_r3611219992


##########
src/main/java/org/apache/sling/cli/impl/release/UpdateDistCommand.java:
##########
@@ -0,0 +1,303 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.cli.impl.release;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Stream;
+
+import org.apache.sling.cli.impl.Command;
+import org.apache.sling.cli.impl.Credentials;
+import org.apache.sling.cli.impl.CredentialsService;
+import org.apache.sling.cli.impl.InputOption;
+import org.apache.sling.cli.impl.UserInput;
+import org.apache.sling.cli.impl.nexus.Artifact;
+import org.apache.sling.cli.impl.nexus.LocalRepository;
+import org.apache.sling.cli.impl.nexus.RepositoryService;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tmatesoft.svn.core.SVNCommitInfo;
+import org.tmatesoft.svn.core.SVNDirEntry;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNURL;
+import org.tmatesoft.svn.core.auth.BasicAuthenticationManager;
+import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
+import org.tmatesoft.svn.core.io.ISVNEditor;
+import org.tmatesoft.svn.core.io.SVNRepository;
+import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
+import org.tmatesoft.svn.core.io.diff.SVNDeltaGenerator;
+import picocli.CommandLine;
+
+/**
+ * Publishes a release's staged artifacts to {@code dist/release/sling} on 
dist.apache.org and removes
+ * the previous release, using SVNKit's pure-Java Subversion client over https.
+ *
+ * <p>This follows the flow used for Maven-based Sling module releases (see 
the Sling release management
+ * guide): the artifacts are downloaded from the Nexus staging repository and 
committed to
+ * {@code dist/release/sling}. Unlike the Sling IDE tooling, Maven releases 
never stage to
+ * {@code dist/dev}. Requires PMC membership to commit to dist.apache.org.
+ */
+@Component(
+        service = Command.class,
+        property = {
+            Command.PROPERTY_NAME_COMMAND_GROUP + "=" + 
UpdateDistCommand.GROUP,
+            Command.PROPERTY_NAME_COMMAND_NAME + "=" + UpdateDistCommand.NAME
+        })
[email protected](
+        name = UpdateDistCommand.NAME,
+        description = "Publishes a release's staged artifacts to dist/release 
on dist.apache.org and removes the"
+                + " previous release. Requires PMC membership.",
+        subcommands = CommandLine.HelpCommand.class)
+public class UpdateDistCommand implements Command {
+
+    static final String GROUP = "release";
+    static final String NAME = "update-dist";
+
+    static final String DIST_RELEASE_URL = 
"https://dist.apache.org/repos/dist/release/sling/";;
+
+    static {
+        // register the http(s):// DAV repository factory used by all SVNKit 
operations below
+        DAVRepositoryFactory.setup();
+    }
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(UpdateDistCommand.class);
+
+    @CommandLine.Option(
+            names = {"-r", "--repository"},
+            description = "Nexus staging repository id",
+            required = true)
+    private Integer repositoryId;
+
+    @CommandLine.Option(

Review Comment:
   Good point — implemented exactly that. When no explicit `--previous-version` 
is given, `update-dist` now removes only the *closest older* version: the 
highest release strictly lower than the one being published, comparing with 
`org.osgi.framework.Version`. So publishing `2.0.4` removes `2.0.2` but keeps 
`1.2.4`, and a newer version is never removed. Covered by new tests 
(`testAutoDeduceRemovesOnlyClosestOlderVersionAcrossStreams`, 
`testAutoDeduceDoesNotConfuseVersionPrefixesAndKeepsNewerVersions`). Fixed in 
dcf3f4f.



##########
src/main/java/org/apache/sling/cli/impl/release/UpdateDistCommand.java:
##########
@@ -0,0 +1,303 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.cli.impl.release;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Stream;
+
+import org.apache.sling.cli.impl.Command;
+import org.apache.sling.cli.impl.Credentials;
+import org.apache.sling.cli.impl.CredentialsService;
+import org.apache.sling.cli.impl.InputOption;
+import org.apache.sling.cli.impl.UserInput;
+import org.apache.sling.cli.impl.nexus.Artifact;
+import org.apache.sling.cli.impl.nexus.LocalRepository;
+import org.apache.sling.cli.impl.nexus.RepositoryService;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tmatesoft.svn.core.SVNCommitInfo;
+import org.tmatesoft.svn.core.SVNDirEntry;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNURL;
+import org.tmatesoft.svn.core.auth.BasicAuthenticationManager;
+import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
+import org.tmatesoft.svn.core.io.ISVNEditor;
+import org.tmatesoft.svn.core.io.SVNRepository;
+import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
+import org.tmatesoft.svn.core.io.diff.SVNDeltaGenerator;
+import picocli.CommandLine;
+
+/**
+ * Publishes a release's staged artifacts to {@code dist/release/sling} on 
dist.apache.org and removes
+ * the previous release, using SVNKit's pure-Java Subversion client over https.
+ *
+ * <p>This follows the flow used for Maven-based Sling module releases (see 
the Sling release management
+ * guide): the artifacts are downloaded from the Nexus staging repository and 
committed to
+ * {@code dist/release/sling}. Unlike the Sling IDE tooling, Maven releases 
never stage to
+ * {@code dist/dev}. Requires PMC membership to commit to dist.apache.org.
+ */
+@Component(
+        service = Command.class,
+        property = {
+            Command.PROPERTY_NAME_COMMAND_GROUP + "=" + 
UpdateDistCommand.GROUP,
+            Command.PROPERTY_NAME_COMMAND_NAME + "=" + UpdateDistCommand.NAME
+        })
[email protected](
+        name = UpdateDistCommand.NAME,
+        description = "Publishes a release's staged artifacts to dist/release 
on dist.apache.org and removes the"
+                + " previous release. Requires PMC membership.",
+        subcommands = CommandLine.HelpCommand.class)
+public class UpdateDistCommand implements Command {
+
+    static final String GROUP = "release";
+    static final String NAME = "update-dist";
+
+    static final String DIST_RELEASE_URL = 
"https://dist.apache.org/repos/dist/release/sling/";;
+
+    static {
+        // register the http(s):// DAV repository factory used by all SVNKit 
operations below
+        DAVRepositoryFactory.setup();
+    }
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(UpdateDistCommand.class);
+
+    @CommandLine.Option(
+            names = {"-r", "--repository"},
+            description = "Nexus staging repository id",
+            required = true)
+    private Integer repositoryId;
+
+    @CommandLine.Option(
+            names = {"--previous-version"},
+            description = "Previous release version to remove from 
dist/release (e.g. 1.0.0)."
+                    + " Optional: if omitted, all older versions currently in 
dist/release are removed.")
+    private String previousVersion;
+
+    @CommandLine.Mixin
+    private ReusableCLIOptions reusableCLIOptions;
+
+    @Reference
+    private RepositoryService repositoryService;
+
+    @Reference
+    private CredentialsService credentialsService;
+
+    @Override
+    public Integer call() {
+        try {
+            LocalRepository localRepository = 
repositoryService.download(repositoryService.find(repositoryId));

Review Comment:
   Nice catch. Root cause: `RepositoryService.download()` only fetched the 
`.asc`/`.sha1`/`.md5` sidecars and never `.sha512`, so the source-release 
`.sha512` was dropped before publishing. Fixed in 6146764 — it now also 
downloads the `.sha512` sidecar. Since the Apache release build emits a 
`.sha512` only for the source-release archive (not for every artifact), the 
download now skips sidecars the repository answers with a non-200 for, instead 
of writing the error body to disk as if it were the file. Added a test 
asserting the source-release `.sha512` is downloaded while artifacts without 
one are not fabricated.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to