diff --git a/packages/vscode-ide-companion/scripts/check-vscode-release.js b/packages/vscode-ide-companion/scripts/check-vscode-release.js index 0298040a02..f2a45d1dd6 100755 --- a/packages/vscode-ide-companion/scripts/check-vscode-release.js +++ b/packages/vscode-ide-companion/scripts/check-vscode-release.js @@ -42,44 +42,54 @@ function checkRelease() { } const lastReleaseVersion = match[1]; const lastReleaseCommit = match[2]; - console.log(`Last release version: ${lastReleaseVersion}`); - console.log(`Last release commit hash: ${lastReleaseCommit}`); // Step 2: Check for new commits - execSync('git fetch origin main'); + execSync('git fetch origin main', { stdio: 'pipe' }); const gitLog = execSync( - `git log ${lastReleaseCommit}..origin/main -- packages/vscode-ide-companion`, + `git log ${lastReleaseCommit}..origin/main --invert-grep --grep="chore(release): bump version to" -- packages/vscode-ide-companion`, { encoding: 'utf-8' }, ).trim(); - if (gitLog) { - console.log( - '\nNew commits found since last release. A new release is needed.', - ); - console.log('---'); - console.log(gitLog); - console.log('---'); - } else { - console.log( - '\nNo new commits found since last release. No release is necessary.', - ); - } - // Step 3: Check for dependency changes const noticesDiff = execSync( `git diff ${lastReleaseCommit}..origin/main -- packages/vscode-ide-companion/NOTICES.txt`, { encoding: 'utf-8' }, ).trim(); + + if (gitLog) { + console.log('\n--- New Commits ---'); + console.log(gitLog); + console.log('-------------------'); + } + + if (noticesDiff) { + console.log('\n--- Dependency Changes ---'); + console.log(noticesDiff); + console.log('------------------------'); + } + + console.log('\n--- Summary ---'); + if (gitLog) { + console.log( + 'New commits found for `packages/vscode-ide-companion` since last release. A new release is needed.', + ); + } else { + console.log( + 'No new commits found since last release. No release is necessary.', + ); + } + if (noticesDiff) { console.log( - '\nDependencies have changed. The license review form will require extra details.', + 'Dependencies have changed. The license review form will require extra details.', ); - console.log('---'); - console.log(noticesDiff); - console.log('---'); } else { - console.log('\nNo dependency changes found.'); + console.log('No dependency changes found.'); } + + console.log(`Last release version: ${lastReleaseVersion}`); + console.log(`Last release commit hash: ${lastReleaseCommit}`); + console.log('---------------'); } catch (error) { console.error('Error checking for release:', error.message); process.exit(1); diff --git a/packages/vscode-ide-companion/src/extension.test.ts b/packages/vscode-ide-companion/src/extension.test.ts index ef99ae670e..49b1b76d43 100644 --- a/packages/vscode-ide-companion/src/extension.test.ts +++ b/packages/vscode-ide-companion/src/extension.test.ts @@ -209,17 +209,34 @@ describe('activate', () => { ide: IDE_DEFINITIONS.cloudshell, }, { ide: IDE_DEFINITIONS.firebasestudio }, - ])('does not show the notification for $ide.name', async ({ ide }) => { - vi.mocked(detectIdeFromEnv).mockReturnValue(ide); - vi.mocked(context.globalState.get).mockReturnValue(undefined); - const showInformationMessageMock = vi.mocked( - vscode.window.showInformationMessage, - ); + ])( + 'does not show install or update messages for $ide.name', + async ({ ide }) => { + vi.mocked(detectIdeFromEnv).mockReturnValue(ide); + vi.mocked(context.globalState.get).mockReturnValue(undefined); + vi.spyOn(global, 'fetch').mockResolvedValue({ + ok: true, + json: async () => ({ + results: [ + { + extensions: [ + { + versions: [{ version: '1.2.0' }], + }, + ], + }, + ], + }), + } as Response); + const showInformationMessageMock = vi.mocked( + vscode.window.showInformationMessage, + ); - await activate(context); + await activate(context); - expect(showInformationMessageMock).not.toHaveBeenCalled(); - }); + expect(showInformationMessageMock).not.toHaveBeenCalled(); + }, + ); it('should not show an update notification if the version is older', async () => { vi.spyOn(global, 'fetch').mockResolvedValue({ diff --git a/packages/vscode-ide-companion/src/extension.ts b/packages/vscode-ide-companion/src/extension.ts index 0bfab851f9..387ef90df5 100644 --- a/packages/vscode-ide-companion/src/extension.ts +++ b/packages/vscode-ide-companion/src/extension.ts @@ -20,11 +20,9 @@ const INFO_MESSAGE_SHOWN_KEY = 'geminiCliInfoMessageShown'; export const DIFF_SCHEME = 'gemini-diff'; /** - * IDE environments where the installation greeting is hidden. In these - * environments we either are pre-installed and the installation message is - * confusing or we just want to be quiet. + * In these environments the companion extension is installed and managed by the IDE instead of the user. */ -const HIDE_INSTALLATION_GREETING_IDES: ReadonlySet = new Set([ +const MANAGED_EXTENSION_SURFACES: ReadonlySet = new Set([ IDE_DEFINITIONS.firebasestudio.name, IDE_DEFINITIONS.cloudshell.name, ]); @@ -37,6 +35,7 @@ let log: (message: string) => void = () => {}; async function checkForUpdates( context: vscode.ExtensionContext, log: (message: string) => void, + isManagedExtensionSurface: boolean, ) { try { const currentVersion = context.extension.packageJSON.version; @@ -81,7 +80,11 @@ async function checkForUpdates( // The versions are sorted by date, so the first one is the latest. const latestVersion = extension?.versions?.[0]?.version; - if (latestVersion && semver.gt(latestVersion, currentVersion)) { + if ( + !isManagedExtensionSurface && + latestVersion && + semver.gt(latestVersion, currentVersion) + ) { const selection = await vscode.window.showInformationMessage( `A new version (${latestVersion}) of the Gemini CLI Companion extension is available.`, 'Update to latest version', @@ -105,7 +108,11 @@ export async function activate(context: vscode.ExtensionContext) { log = createLogger(context, logger); log('Extension activated'); - checkForUpdates(context, log); + const isManagedExtensionSurface = MANAGED_EXTENSION_SURFACES.has( + detectIdeFromEnv().name, + ); + + checkForUpdates(context, log, isManagedExtensionSurface); const diffContentProvider = new DiffContentProvider(); const diffManager = new DiffManager(log, diffContentProvider); @@ -148,11 +155,10 @@ export async function activate(context: vscode.ExtensionContext) { log(`Failed to start IDE server: ${message}`); } - const infoMessageEnabled = !HIDE_INSTALLATION_GREETING_IDES.has( - detectIdeFromEnv().name, - ); - - if (!context.globalState.get(INFO_MESSAGE_SHOWN_KEY) && infoMessageEnabled) { + if ( + !context.globalState.get(INFO_MESSAGE_SHOWN_KEY) && + !isManagedExtensionSurface + ) { void vscode.window.showInformationMessage( 'Gemini CLI Companion extension successfully installed.', );