Skip to content

Commit e7a3265

Browse files
committed
#139015 set hasReleseVersion to true
- avoids additional request to check if extension has release version - improve error handling when release version is not found
1 parent fb26bec commit e7a3265

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

src/vs/platform/extensionManagement/common/abstractExtensionManagementService.ts

+4
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,10 @@ export abstract class AbstractExtensionManagementService extends Disposable impl
373373
throw new ExtensionManagementError(nls.localize('notFoundCompatiblePrereleaseDependency', "Can't install pre-release version of '{0}' extension because it is not compatible with the current version of {1} (version {2}).", extension.identifier.id, this.productService.nameLong, this.productService.version), ExtensionManagementErrorCode.IncompatiblePreRelease);
374374
}
375375
} else {
376+
/** If no compatible release version is found, check if the extension has a release version or not and throw relevant error */
377+
if (!installPreRelease && extension.properties.isPreReleaseVersion && (await this.galleryService.getExtensions([extension.identifier], CancellationToken.None))[0]) {
378+
throw new ExtensionManagementError(nls.localize('notFoundReleaseExtension', "Can't install release version of '{0}' extension because it has no release version.", extension.identifier.id), ExtensionManagementErrorCode.ReleaseVersionNotFound);
379+
}
376380
throw new ExtensionManagementError(nls.localize('notFoundCompatibleDependency', "Can't install '{0}' extension because it is not compatible with the current version of {1} (version {2}).", extension.identifier.id, this.productService.nameLong, this.productService.version), ExtensionManagementErrorCode.Incompatible);
377381
}
378382

src/vs/platform/extensionManagement/common/extensionGalleryService.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,6 @@ export function sortExtensionVersions(versions: IRawGalleryExtensionVersion[], p
474474

475475
function toExtension(galleryExtension: IRawGalleryExtension, version: IRawGalleryExtensionVersion, allTargetPlatforms: TargetPlatform[]): IGalleryExtension {
476476
const latestVersion = galleryExtension.versions[0];
477-
const hasReleaseVersion = galleryExtension.versions.some(version => !isPreReleaseVersion(version));
478477
const assets = <IGalleryExtensionAssets>{
479478
manifest: getVersionAsset(version, AssetType.Manifest),
480479
readme: getVersionAsset(version, AssetType.Details),
@@ -517,7 +516,7 @@ function toExtension(galleryExtension: IRawGalleryExtension, version: IRawGaller
517516
isPreReleaseVersion: isPreReleaseVersion(version)
518517
},
519518
hasPreReleaseVersion: isPreReleaseVersion(latestVersion),
520-
hasReleaseVersion,
519+
hasReleaseVersion: true,
521520
preview: getIsPreview(galleryExtension.flags),
522521
};
523522
}
@@ -774,10 +773,16 @@ abstract class AbstractExtensionGalleryService implements IExtensionGalleryServi
774773
const needAllVersions = new Map<string, number>();
775774
for (let index = 0; index < rawGalleryExtensions.length; index++) {
776775
const rawGalleryExtension = rawGalleryExtensions[index];
776+
const extensionIdentifier = { id: getGalleryExtensionId(rawGalleryExtension.publisher.publisherName, rawGalleryExtension.extensionName), uuid: rawGalleryExtension.extensionId };
777+
const preRelease = isBoolean(criteria.preRelease) ? criteria.preRelease : !!criteria.preRelease.find(extensionIdentifierWithPreRelease => areSameExtensions(extensionIdentifierWithPreRelease, extensionIdentifier))?.preRelease;
777778
let extension = await this.toGalleryExtensionWithCriteria(rawGalleryExtension, criteria, false);
778779
if (!extension
779-
/* Skip if it is a pre-release version. Need all versions to know if there is a release version */
780-
|| extension.properties.isPreReleaseVersion
780+
/** Skip if the extension is a pre-release version but
781+
* - the query is to look for a release version or
782+
* - the extension has no release version
783+
* Get all versions to get or check the release version
784+
*/
785+
|| (extension.properties.isPreReleaseVersion && (!preRelease || !extension.hasReleaseVersion))
781786
/**
782787
* Skip if the extension is a release version with a different target platform than requested and also has a pre-release version
783788
* Because, this is a platform specific extension and can have a newer release version supporting this platform.

src/vs/platform/extensionManagement/common/extensionManagement.ts

+1
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ export enum ExtensionManagementErrorCode {
373373
Incompatible = 'Incompatible',
374374
IncompatiblePreRelease = 'IncompatiblePreRelease',
375375
IncompatibleTargetPlatform = 'IncompatibleTargetPlatform',
376+
ReleaseVersionNotFound = 'ReleaseVersionNotFound',
376377
Invalid = 'Invalid',
377378
Download = 'Download',
378379
Extract = 'Extract',

src/vs/workbench/contrib/extensions/browser/extensionsActions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class PromptExtensionInstallFailureAction extends Action {
104104
return;
105105
}
106106

107-
if ([ExtensionManagementErrorCode.Incompatible, ExtensionManagementErrorCode.IncompatibleTargetPlatform, ExtensionManagementErrorCode.Malicious, ExtensionManagementErrorCode.UnsupportedPreRelease].includes(<ExtensionManagementErrorCode>this.error.name)) {
107+
if ([ExtensionManagementErrorCode.Incompatible, ExtensionManagementErrorCode.IncompatibleTargetPlatform, ExtensionManagementErrorCode.Malicious, ExtensionManagementErrorCode.ReleaseVersionNotFound, ExtensionManagementErrorCode.UnsupportedPreRelease].includes(<ExtensionManagementErrorCode>this.error.name)) {
108108
await this.dialogService.show(Severity.Info, getErrorMessage(this.error));
109109
return;
110110
}

0 commit comments

Comments
 (0)