From 80fdfe92599a1dcad9b55e223c113347b7589dfb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Jun 2025 08:56:42 +0000 Subject: [PATCH 1/4] Initial plan From 111f7211bf7592bc4a79d3c502fc694bbc326771 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Jun 2025 09:00:35 +0000 Subject: [PATCH 2/4] Initial analysis: false upgrade notification due to regex extracting version from file paths Co-authored-by: garrytrinder <11563347+garrytrinder@users.noreply.github.com> --- package-lock.json | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6ab89b8..1650189 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,27 +8,27 @@ "name": "dev-proxy-toolkit", "version": "0.26.0", "dependencies": { - "json-to-ast": "^2.1.0", - "semver": "^7.7.2" + "json-to-ast": "2.1.0", + "semver": "7.7.2" }, "devDependencies": { - "@types/json-to-ast": "^2.1.4", - "@types/mocha": "^10.0.9", - "@types/node": "^24.0.3", - "@types/sinon": "^17.0.4", - "@types/vscode": "^1.98.0", - "@typescript-eslint/eslint-plugin": "^8.29.0", - "@typescript-eslint/parser": "^8.29.0", - "@vscode/test-cli": "^0.0.11", - "@vscode/test-electron": "^2.4.1", - "copy-webpack-plugin": "^13.0.0", - "eslint": "^9.23.0", - "gts": "^6.0.2", - "sinon": "^21.0.0", - "ts-loader": "^9.5.2", - "typescript": "^5.8.2", - "webpack": "^5.98.0", - "webpack-cli": "^6.0.1" + "@types/json-to-ast": "2.1.4", + "@types/mocha": "10.0.10", + "@types/node": "24.0.3", + "@types/sinon": "17.0.4", + "@types/vscode": "1.101.0", + "@typescript-eslint/eslint-plugin": "8.35.0", + "@typescript-eslint/parser": "8.35.0", + "@vscode/test-cli": "0.0.11", + "@vscode/test-electron": "2.5.2", + "copy-webpack-plugin": "13.0.0", + "eslint": "9.29.0", + "gts": "6.0.2", + "sinon": "21.0.0", + "ts-loader": "9.5.2", + "typescript": "5.8.3", + "webpack": "5.99.9", + "webpack-cli": "6.0.1" }, "engines": { "vscode": "^1.101.0" From e31b4bf875418a398bb9a1e1a8ed8b6777122208 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Jun 2025 09:03:10 +0000 Subject: [PATCH 3/4] Fix false upgrade notifications by improving version extraction regex - Update extractVersionFromOutput to skip file paths and only extract versions from actual update notification lines - Add comprehensive tests for issue #286 scenarios including Windows paths - Preserve existing functionality for all current test cases Co-authored-by: garrytrinder <11563347+garrytrinder@users.noreply.github.com> --- src/detect.ts | 28 +++++++++++++++++++++++----- src/test/extension.test.ts | 30 ++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/src/detect.ts b/src/detect.ts index 96b70e2..354a520 100644 --- a/src/detect.ts +++ b/src/detect.ts @@ -41,11 +41,29 @@ export const extractVersionFromOutput = (output: string): string => { return ''; } - // Extract version number using semver pattern - // Matches: major.minor.patch[-prerelease][+build] but only captures up to prerelease - const semverRegex = /v?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?)(?:\+[a-zA-Z0-9.-]+)?/; - const match = output.match(semverRegex); - return match ? match[1] : ''; + // Split into lines and look for version information on dedicated lines + // This avoids extracting versions from file paths like /opt/homebrew/Cellar/dev-proxy/v0.29.1/devproxy-errors.json + const lines = output.split('\n'); + + // Look for lines that contain version information (not file paths) + for (const line of lines) { + const trimmedLine = line.trim(); + + // Skip lines that contain file paths (indicated by slashes and common path patterns) + if (trimmedLine.includes('/') || trimmedLine.includes('\\') || trimmedLine.includes('loaded from')) { + continue; + } + + // Look for version pattern on non-filepath lines + // Matches: major.minor.patch[-prerelease][+build] but only captures up to prerelease + const semverRegex = /v?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?)(?:\+[a-zA-Z0-9.-]+)?/; + const match = trimmedLine.match(semverRegex); + if (match) { + return match[1]; + } + } + + return ''; }; export const getOutdatedVersion = async (devProxyExe: string): Promise => { diff --git a/src/test/extension.test.ts b/src/test/extension.test.ts index 252bb4d..c51da01 100644 --- a/src/test/extension.test.ts +++ b/src/test/extension.test.ts @@ -625,4 +625,34 @@ suite('extractVersionFromOutput', () => { const result = detect.extractVersionFromOutput(output); assert.strictEqual(result, '1.0.0-beta.1'); }); + + test('should not extract version from file paths in error responses (issue #286)', () => { + const output = `info 1 error responses loaded from /opt/homebrew/Cellar/dev-proxy/v0.29.1/devproxy-errors.json`; + + const result = detect.extractVersionFromOutput(output); + assert.strictEqual(result, ''); + }); + + test('should extract version from update notification line, ignoring file paths (issue #286)', () => { + const output = `info 1 error responses loaded from /opt/homebrew/Cellar/dev-proxy/v0.29.0/devproxy-errors.json +info v0.29.1`; + + const result = detect.extractVersionFromOutput(output); + assert.strictEqual(result, '0.29.1'); + }); + + test('should not extract version from Windows file paths', () => { + const output = `info 1 error responses loaded from C:\\Program Files\\dev-proxy\\v0.29.1\\devproxy-errors.json`; + + const result = detect.extractVersionFromOutput(output); + assert.strictEqual(result, ''); + }); + + test('should extract version from actual update notification with Windows paths in earlier lines', () => { + const output = `info 1 error responses loaded from C:\\Program Files\\dev-proxy\\v0.29.0\\devproxy-errors.json +info v0.29.1`; + + const result = detect.extractVersionFromOutput(output); + assert.strictEqual(result, '0.29.1'); + }); }); From d446564884fd6d0535fb5c03a68f1772e27d2b04 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 27 Jun 2025 09:33:13 +0000 Subject: [PATCH 4/4] Add comprehensive test coverage for beta version extraction (issue #286) Co-authored-by: garrytrinder <11563347+garrytrinder@users.noreply.github.com> --- src/test/extension.test.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/test/extension.test.ts b/src/test/extension.test.ts index c51da01..983adc9 100644 --- a/src/test/extension.test.ts +++ b/src/test/extension.test.ts @@ -655,4 +655,34 @@ info v0.29.1`; const result = detect.extractVersionFromOutput(output); assert.strictEqual(result, '0.29.1'); }); + + test('should not extract beta version from Unix file paths (issue #286)', () => { + const output = `info 1 error responses loaded from /opt/homebrew/Cellar/dev-proxy/v0.30.0-beta.2/devproxy-errors.json`; + + const result = detect.extractVersionFromOutput(output); + assert.strictEqual(result, ''); + }); + + test('should not extract beta version from Windows file paths (issue #286)', () => { + const output = `info 1 error responses loaded from C:\\Program Files\\dev-proxy\\v0.30.0-beta.2\\devproxy-errors.json`; + + const result = detect.extractVersionFromOutput(output); + assert.strictEqual(result, ''); + }); + + test('should extract beta version from update notification, ignoring file paths (issue #286)', () => { + const output = `info 1 error responses loaded from /opt/homebrew/Cellar/dev-proxy/v0.30.0-beta.1/devproxy-errors.json +info v0.30.0-beta.2`; + + const result = detect.extractVersionFromOutput(output); + assert.strictEqual(result, '0.30.0-beta.2'); + }); + + test('should extract beta version from update notification with Windows paths in earlier lines (issue #286)', () => { + const output = `info 1 error responses loaded from C:\\Program Files\\dev-proxy\\v0.30.0-beta.1\\devproxy-errors.json +info v0.30.0-beta.2`; + + const result = detect.extractVersionFromOutput(output); + assert.strictEqual(result, '0.30.0-beta.2'); + }); });