From 7eb89b4189e42f6858721afc9f383a19f7dc1688 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Fri, 4 Apr 2025 13:36:00 +0200 Subject: [PATCH] fix: add/remove leading 0 when needed --- get_repo.sh | 2 +- patches/version-1-update.patch | 24 +++++++++++++----------- update_version.sh | 22 +++++++++++++--------- utils.sh | 2 +- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/get_repo.sh b/get_repo.sh index bbb12ca..4ebd9a7 100755 --- a/get_repo.sh +++ b/get_repo.sh @@ -27,7 +27,7 @@ if [[ -z "${RELEASE_VERSION}" ]]; then fi fi - TIME_PATCH=$(($(date +%-j) * 24 + $(date +%-H))) + TIME_PATCH=$( printf "%04d" $(($(date +%-j) * 24 + $(date +%-H))) ) if [[ "${VSCODE_QUALITY}" == "insider" ]]; then RELEASE_VERSION="${MS_TAG}${TIME_PATCH}-insider" diff --git a/patches/version-1-update.patch b/patches/version-1-update.patch index 91cb62d..7dcd1d3 100644 --- a/patches/version-1-update.patch +++ b/patches/version-1-update.patch @@ -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 -index 57398fb..fb6db8b 100644 +index 57398fb..b30ef50 100644 --- a/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'; @@ -91,7 +91,7 @@ index 57398fb..fb6db8b 100644 - const url = createUpdateURL(assetID, quality, this.productService); + const url = createUpdateURL(this.productService, quality, process.platform, process.arch); 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 { + if (!this.url) { + return; @@ -109,9 +109,10 @@ index 57398fb..fb6db8b 100644 + 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)); + } + else { @@ -131,7 +132,7 @@ index dd18900..920dc10 100644 + 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 -index db92de2..896a301 100644 +index db92de2..2bbdad9 100644 --- a/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'; @@ -192,26 +193,27 @@ index db92de2..896a301 100644 - return createUpdateURL(platform, quality, this.productService); + 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)); + return Promise.resolve(null); + } + 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 = getUpdateType() == UpdateType.Setup && this.configurationService.getValue('update.enableWindowsBackgroundUpdates'); 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 => { - this.telemetryService.publicLog2<{ messageHash: string }, UpdateErrorClassification>('update:error', { messageHash: String(hash(String(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 { - spawn(this.availableUpdate.packagePath, ['/silent', '/log', '/mergetasks=runcode,!desktopicon,!quicklaunchicon'], { - detached: true, diff --git a/update_version.sh b/update_version.sh index 213165e..f139d03 100755 --- a/update_version.sh +++ b/update_version.sh @@ -95,18 +95,22 @@ generateJson() { } transformVersion() { - local version + local version parts - version="$1" + version="${1%-insider}" - # Check if the version ends with -insider - if [[ "${version}" == *-insider ]]; then - # Remove -insider suffix, add .0 before it - echo "${version%-insider}.0-insider" - else - # Just add .0 at the end - echo "${version}.0" + IFS='.' read -r -a parts <<< "${version}" + + # Remove leading zeros from third part + parts[2]="$((10#${parts[2]}))" + + version="${parts[0]}.${parts[1]}.${parts[2]}.0" + + if [[ "${1}" == *-insider ]]; then + version="${version}-insider" fi + + echo "${version}" } updateLatestVersion() { diff --git a/utils.sh b/utils.sh index ae78768..221b96f 100755 --- a/utils.sh +++ b/utils.sh @@ -27,7 +27,7 @@ apply_patch() { exit 1 fi - mv -f "$1.bak" $1 + mv -f $1{.bak,} } exists() { type -t "$1" &> /dev/null; }