fix: add/remove leading 0 when needed

This commit is contained in:
Baptiste Augrain
2025-04-04 13:36:00 +02:00
parent 4102592509
commit 7eb89b4189
4 changed files with 28 additions and 22 deletions

View File

@@ -27,7 +27,7 @@ if [[ -z "${RELEASE_VERSION}" ]]; then
fi fi
fi fi
TIME_PATCH=$(($(date +%-j) * 24 + $(date +%-H))) TIME_PATCH=$( printf "%04d" $(($(date +%-j) * 24 + $(date +%-H))) )
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
RELEASE_VERSION="${MS_TAG}${TIME_PATCH}-insider" RELEASE_VERSION="${MS_TAG}${TIME_PATCH}-insider"

View File

@@ -67,7 +67,7 @@ index a1ec3fe..f954720 100644
+ } + }
} }
diff --git a/src/vs/platform/update/electron-main/updateService.darwin.ts b/src/vs/platform/update/electron-main/updateService.darwin.ts diff --git a/src/vs/platform/update/electron-main/updateService.darwin.ts b/src/vs/platform/update/electron-main/updateService.darwin.ts
index 57398fb..fb6db8b 100644 index 57398fb..b30ef50 100644
--- a/src/vs/platform/update/electron-main/updateService.darwin.ts --- a/src/vs/platform/update/electron-main/updateService.darwin.ts
+++ b/src/vs/platform/update/electron-main/updateService.darwin.ts +++ b/src/vs/platform/update/electron-main/updateService.darwin.ts
@@ -15,3 +15,3 @@ import { ILogService } from '../../log/common/log.js'; @@ -15,3 +15,3 @@ import { ILogService } from '../../log/common/log.js';
@@ -91,7 +91,7 @@ index 57398fb..fb6db8b 100644
- const url = createUpdateURL(assetID, quality, this.productService); - const url = createUpdateURL(assetID, quality, this.productService);
+ const url = createUpdateURL(this.productService, quality, process.platform, process.arch); + const url = createUpdateURL(this.productService, quality, process.platform, process.arch);
try { try {
@@ -94,4 +90,28 @@ export class DarwinUpdateService extends AbstractUpdateService implements IRelau @@ -94,4 +90,29 @@ export class DarwinUpdateService extends AbstractUpdateService implements IRelau
protected doCheckForUpdates(context: any): void { protected doCheckForUpdates(context: any): void {
+ if (!this.url) { + if (!this.url) {
+ return; + return;
@@ -109,9 +109,10 @@ index 57398fb..fb6db8b 100644
+ return Promise.resolve(null); + return Promise.resolve(null);
+ } + }
+ +
+ const fetchedVersion = /\d+\.\d+\.\d+\.\d+/.test(update.productVersion) ? update.productVersion.replace(/(\d+\.\d+\.\d+)\.\d+(\-\w+)?/, '$1$2') : update.productVersion + const fetchedVersion = /\d+\.\d+\.\d+\.\d+/.test(update.productVersion) ? update.productVersion.replace(/(\d+\.\d+\.\d+)\.\d+(\-\w+)?/, '$1$2') : update.productVersion.replace(/(\d+\.\d+\.)0+(\d+)(\-\w+)?/, '$1$2$3')
+ const currentVersion = this.productService.version.replace(/(\d+\.\d+\.)0+(\d+)(\-\w+)?/, '$1$2$3')
+ +
+ if(semver.compareBuild(this.productService.version, fetchedVersion) >= 0) { + if(semver.compareBuild(currentVersion, fetchedVersion) >= 0) {
+ this.setState(State.Idle(UpdateType.Setup)); + this.setState(State.Idle(UpdateType.Setup));
+ } + }
+ else { + else {
@@ -131,7 +132,7 @@ index dd18900..920dc10 100644
+ return createUpdateURL(this.productService, quality, process.platform, process.arch); + return createUpdateURL(this.productService, quality, process.platform, process.arch);
} }
diff --git a/src/vs/platform/update/electron-main/updateService.win32.ts b/src/vs/platform/update/electron-main/updateService.win32.ts diff --git a/src/vs/platform/update/electron-main/updateService.win32.ts b/src/vs/platform/update/electron-main/updateService.win32.ts
index db92de2..896a301 100644 index db92de2..2bbdad9 100644
--- a/src/vs/platform/update/electron-main/updateService.win32.ts --- a/src/vs/platform/update/electron-main/updateService.win32.ts
+++ b/src/vs/platform/update/electron-main/updateService.win32.ts +++ b/src/vs/platform/update/electron-main/updateService.win32.ts
@@ -11,3 +11,2 @@ import { CancellationToken } from '../../../base/common/cancellation.js'; @@ -11,3 +11,2 @@ import { CancellationToken } from '../../../base/common/cancellation.js';
@@ -192,26 +193,27 @@ index db92de2..896a301 100644
- return createUpdateURL(platform, quality, this.productService); - return createUpdateURL(platform, quality, this.productService);
+ return createUpdateURL(this.productService, quality, process.platform, process.arch, target); + return createUpdateURL(this.productService, quality, process.platform, process.arch, target);
} }
@@ -130,2 +145,9 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun @@ -130,2 +145,10 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun
+ const fetchedVersion = /\d+\.\d+\.\d+\.\d+/.test(update.productVersion) ? update.productVersion.replace(/(\d+\.\d+\.\d+)\.\d+(\-\w+)?/, '$1$2') : update.productVersion + const fetchedVersion = /\d+\.\d+\.\d+\.\d+/.test(update.productVersion) ? update.productVersion.replace(/(\d+\.\d+\.\d+)\.\d+(\-\w+)?/, '$1$2') : update.productVersion.replace(/(\d+\.\d+\.)0+(\d+)(\-\w+)?/, '$1$2$3')
+ const currentVersion = this.productService.version.replace(/(\d+\.\d+\.)0+(\d+)(\-\w+)?/, '$1$2$3')
+ +
+ if(semver.compareBuild(this.productService.version, fetchedVersion) >= 0) { + if(semver.compareBuild(currentVersion, fetchedVersion) >= 0) {
+ this.setState(State.Idle(updateType)); + this.setState(State.Idle(updateType));
+ return Promise.resolve(null); + return Promise.resolve(null);
+ } + }
+ +
if (updateType === UpdateType.Archive) { if (updateType === UpdateType.Archive) {
@@ -156,3 +178,3 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun @@ -156,3 +179,3 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun
- const fastUpdatesEnabled = this.configurationService.getValue('update.enableWindowsBackgroundUpdates'); - const fastUpdatesEnabled = this.configurationService.getValue('update.enableWindowsBackgroundUpdates');
+ const fastUpdatesEnabled = getUpdateType() == UpdateType.Setup && this.configurationService.getValue('update.enableWindowsBackgroundUpdates'); + const fastUpdatesEnabled = getUpdateType() == UpdateType.Setup && this.configurationService.getValue('update.enableWindowsBackgroundUpdates');
if (fastUpdatesEnabled) { if (fastUpdatesEnabled) {
@@ -168,3 +190,2 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun @@ -168,3 +191,2 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun
.then(undefined, err => { .then(undefined, err => {
- this.telemetryService.publicLog2<{ messageHash: string }, UpdateErrorClassification>('update:error', { messageHash: String(hash(String(err))) }); - this.telemetryService.publicLog2<{ messageHash: string }, UpdateErrorClassification>('update:error', { messageHash: String(hash(String(err))) });
this.logService.error(err); this.logService.error(err);
@@ -252,6 +273,14 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun @@ -252,6 +274,14 @@ export class Win32UpdateService extends AbstractUpdateService implements IRelaun
} else { } else {
- spawn(this.availableUpdate.packagePath, ['/silent', '/log', '/mergetasks=runcode,!desktopicon,!quicklaunchicon'], { - spawn(this.availableUpdate.packagePath, ['/silent', '/log', '/mergetasks=runcode,!desktopicon,!quicklaunchicon'], {
- detached: true, - detached: true,

View File

@@ -95,18 +95,22 @@ generateJson() {
} }
transformVersion() { transformVersion() {
local version local version parts
version="$1" version="${1%-insider}"
# Check if the version ends with -insider IFS='.' read -r -a parts <<< "${version}"
if [[ "${version}" == *-insider ]]; then
# Remove -insider suffix, add .0 before it # Remove leading zeros from third part
echo "${version%-insider}.0-insider" parts[2]="$((10#${parts[2]}))"
else
# Just add .0 at the end version="${parts[0]}.${parts[1]}.${parts[2]}.0"
echo "${version}.0"
if [[ "${1}" == *-insider ]]; then
version="${version}-insider"
fi fi
echo "${version}"
} }
updateLatestVersion() { updateLatestVersion() {

View File

@@ -27,7 +27,7 @@ apply_patch() {
exit 1 exit 1
fi fi
mv -f "$1.bak" $1 mv -f $1{.bak,}
} }
exists() { type -t "$1" &> /dev/null; } exists() { type -t "$1" &> /dev/null; }