Skip to content

Commit

Permalink
[FIXUP] Preserve specified empty versions
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Oct 14, 2024
1 parent 4aa3ee0 commit b407740
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,23 @@
*/
public class IUBundleContainer extends AbstractBundleContainer {

record UnitDeclaration(String id, VersionRange version) {
record UnitDeclaration(String id, VersionRange version, boolean hasVersion) {
private static final String EMPTY_VERSION = Version.emptyVersion.toString();

static UnitDeclaration parse(String id, String version) {
version = version.strip();
if (version.isEmpty() || version.equals(EMPTY_VERSION)) {
return new UnitDeclaration(id, VersionRange.emptyRange);
return new UnitDeclaration(id, VersionRange.emptyRange, !version.isEmpty());
} else if (version.contains(",")) { //$NON-NLS-1$
return new UnitDeclaration(id, VersionRange.create(version));
return new UnitDeclaration(id, VersionRange.create(version), true);
} else {
return create(id, Version.parseVersion(version));
}
}

static UnitDeclaration create(String id, Version version) {
VersionRange range = new VersionRange(version, true, version, true);
return new UnitDeclaration(id, range);
return new UnitDeclaration(id, range, true);
}

UnitDeclaration {
Expand Down Expand Up @@ -746,7 +746,7 @@ public String serialize() {
fIUs.stream().sorted(BY_ID_THEN_VERSION).forEach(iu -> {
Element unit = document.createElement(TargetDefinitionPersistenceHelper.INSTALLABLE_UNIT);
unit.setAttribute(TargetDefinitionPersistenceHelper.ATTR_ID, iu.id());
if (!iu.hasEmptyVersion()) {
if (iu.hasVersion()) {
unit.setAttribute(TargetDefinitionPersistenceHelper.ATTR_VERSION, iu.versionString());
}
containerElement.appendChild(unit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ public class EditIUContainerPage extends WizardPage implements IEditBundleContai
private static final int REFRESH_INTERVAL = 4000;
private static final int REFRESH_TRIES = 10;

private static final String EMPTY_VERSION = Version.emptyVersion.toString();
private static final String LATEST_LABEL = Messages.EditIUContainerPage_Latest_Label;

/**
* If the user is only downloading from a specific repository location, we store it here so it can be persisted in the target
*/
Expand Down Expand Up @@ -337,9 +340,6 @@ protected CellEditor getCellEditor(Object element) {
return treeViewer;
}

private static final String EMPTY_VERSION = Version.emptyVersion.toString();
private static final String LATEST_LABEL = Messages.EditIUContainerPage_Latest_Label;

private static String sanitizeVersionSpecification(String spec) {
spec = spec.strip();
return LATEST_LABEL.equals(spec) ? EMPTY_VERSION : spec;
Expand Down

0 comments on commit b407740

Please sign in to comment.