Croway commented on code in PR #29428:
URL: https://github.com/apache/camel/pull/29428#discussion_r4511584187
##########
dsl/camel-jbang/camel-launcher/src/main/java/org/apache/camel/dsl/jbang/launcher/selfupdate/SelfUpdateCommand.java:
##########
@@ -86,23 +93,42 @@ public Integer doCall() throws Exception {
// only within its selector, so an explicit --version, which could
leave it, is refused as well.
Optional<String> pinned = InstallDetector.pinnedVersion();
Pin pin = pinned.map(Pin::parse).orElse(null);
- if (pin != null && !pin.tracksAlias()) {
+ if (pin != null && !pin.tracksAlias() && !pin.followsNightlies()) {
printer().printErr("this install is pinned to version " +
pinned.get() + " - remove "
+ InstallDetector.pinnedVersionFile() + " to
resume tracking new releases");
return 1;
}
- if (pin != null && version != null) {
+ if (pin != null && pin.tracksAlias() && version != null) {
// Removing the pin file would make the install track the latest
release, which is not what asking for
// one version means, so point at the installer, which replaces
the selector pin with an exact one.
printer().printErr(selectorPinRefusal(pin, version));
return 1;
}
ManifestFetcher fetcher = fetcherOverride != null ? fetcherOverride :
ManifestFetcher.fromEnvironment();
+ if (version != null && Nightly.isNightly(version)) {
+ return updateToNightly(fetcher, info, Nightly.normalize(version),
true);
+ }
+ if (version == null && pin != null && pin.followsNightlies()) {
Review Comment:
**2. An `X.Y.Z-SNAPSHOT` pin does not notice that X.Y.Z was released.**
Setup: pin `9.9.0-SNAPSHOT`, running its last nightly. 9.9.0 is published as
latest and LTS, and the root metadata lists 9.10.0-SNAPSHOT as main. Both
`--check` and a plain `camel self-update` print:
```
Camel CLI is already on the newest nightly build for the nightly builds of
9.9.0-SNAPSHOT (9.9.0-20261108.143653-24)
```
The user stays on a pre-release of a version that is already GA, with no
hint (and `UpdateChecker` stays quiet for nightly pins, by design). Once the
snapshot is removed from the repository, every run fails:
```
ERROR: no nightly builds of 9.9.0-SNAPSHOT at
https://.../9.9.0-SNAPSHOT/maven-metadata.xml
```
That removal does happen on repository.apache.org. The root metadata of
`camel-launcher` lists only 4.14.10, 4.18.6, 4.22.3 and 4.24.0-SNAPSHOT today,
and `4.22.2-SNAPSHOT/maven-metadata.xml` returns 404. Control: a `SNAPSHOT` pin
in the same setup moves on to the 9.10.0 nightly.
Suggestion: when the pinned snapshot version is no longer listed in the root
metadata, or the release X.Y.Z exists, say so and name the way out (`--version
X.Y.Z`, `--version SNAPSHOT`, or the next `X.Y.Z-SNAPSHOT`) instead of the bare
404 message.
_Claude Code on behalf of @Croway_
##########
dsl/camel-jbang/camel-launcher/src/main/java/org/apache/camel/dsl/jbang/launcher/selfupdate/SelfUpdateCommand.java:
##########
@@ -86,23 +93,42 @@ public Integer doCall() throws Exception {
// only within its selector, so an explicit --version, which could
leave it, is refused as well.
Optional<String> pinned = InstallDetector.pinnedVersion();
Pin pin = pinned.map(Pin::parse).orElse(null);
- if (pin != null && !pin.tracksAlias()) {
+ if (pin != null && !pin.tracksAlias() && !pin.followsNightlies()) {
printer().printErr("this install is pinned to version " +
pinned.get() + " - remove "
+ InstallDetector.pinnedVersionFile() + " to
resume tracking new releases");
return 1;
}
- if (pin != null && version != null) {
+ if (pin != null && pin.tracksAlias() && version != null) {
Review Comment:
**3. Since 936e87f, `self-update` writes LTS and X.Y pins, then refuses its
own `--version SNAPSHOT` with advice that does not fit.**
ammachado listed "an LTS or X.Y pin with `--version SNAPSHOT`, which must be
refused" as a test gap, so the refusal itself may be intended. Two things still
look off. Here are the last two docs examples run in order (`--version LTS`,
then `--version SNAPSHOT`), with `install.sh` as control:
```
$ camel self-update --version LTS # exit 0, pinned-version = LTS
$ camel self-update --version SNAPSHOT # exit 1
ERROR: this install is pinned to LTS - to pin an exact version instead,
re-run the installer with --version X.Y.Z
$ camel self-update --version 99.0 # exit 1, same message
$ sh install.sh --version SNAPSHOT # exit 0, pinned-version = SNAPSHOT
```
1. The message tells a user who asked for nightly builds to pin an exact
release. `selectorPinRefusal` only quotes the installer command for an `X.Y.Z`
request. For `SNAPSHOT`, `X.Y.Z-SNAPSHOT`, `LTS` and `X.Y`, it could quote the
same command with the requested value.
2. It only works in one direction. A `SNAPSHOT` pin can switch with
`--version LTS` (`ltsLeavesTheNightliesAndPinsLts`), but an LTS pin cannot
switch with `--version SNAPSHOT`. Before this PR, `self-update` never wrote a
pin, so it could not lock out its own `--version`. The docs sentence
"`--version LTS` and `--version X.Y` install the newest release of that
selector and pin it, from `camel self-update` as from the installer" holds only
while no LTS or X.Y pin exists. Either allow switching from one selector to
another (as `install.sh` does, and as the SNAPSHOT to LTS direction already
does), or say in the docs that `self-update` does not switch away from an LTS
or X.Y pin.
_Claude Code on behalf of @Croway_
--
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]