Loading src/constants.ts +2 −1 Original line number Diff line number Diff line Loading @@ -7,4 +7,5 @@ export const DELETED = 'deleted'; export const RENAMED = 'renamed'; export const MODIFIED = 'modified'; export const DO_NOT_SHOW_VERSION_WARNING = 'DO_NOT_SHOW_VERSION_WARNING'; export const MINIMUM_VERSION = 13.5; // NOTE: This needs to _always_ be a 3 digits export const MINIMUM_VERSION = '13.5.0'; src/utils/check_version.test.ts +3 −2 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ describe('check_version', () => { ${'13.5.0'} ${'13.6.3'} ${'13.6.0-pre'} ${'13.6.0-pre-1'} ${'13.12.4'} ${'abc13.5def'} `('gets $version successfully', async ({ version }) => { Loading @@ -57,7 +58,7 @@ describe('check_version', () => { expect(vscode.window.showErrorMessage).not.toHaveBeenCalled(); }); xit(`shows warning when version is below 13.5`, async () => { it(`shows warning when version is below 13.5`, async () => { mockedRepositories = [createMockRepo(`13.4.2`)]; await getVersionForEachRepo(gitExtensionWrapper, context as vscode.ExtensionContext); Loading @@ -72,7 +73,7 @@ describe('check_version', () => { expect(logMock.log).toHaveBeenCalledWith(`Could not match version from "${BAD_VERSION}"`); }); xit('stores user preference for not showing the warning', async () => { it('stores user preference for not showing the warning', async () => { mockedRepositories = [createMockRepo('13.4')]; (vscode.window.showErrorMessage as jest.Mock).mockResolvedValue('Do not show again'); Loading src/utils/check_version.ts +19 −13 Original line number Diff line number Diff line Loading @@ -8,31 +8,37 @@ export const getVersionForEachRepo = async ( context: vscode.ExtensionContext, ): Promise<void> => { const DO_NOT_SHOW_AGAIN_TEXT = 'Do not show again'; const toSegments = (version?: string) => { const match = version?.match(/\d+/g) || []; return match.map(Number); }; const minimumSegments = toSegments(MINIMUM_VERSION); await Promise.all( gitExtensionWrapper.repositories.map(async repo => { const version = await repo.getVersion(); const versionMatch = version?.match(/\d+\.\d+/); if (!versionMatch) { log(`Could not match version from "${version}"`); const repoVersion = await repo.getVersion(); const versionSegments = toSegments(repoVersion); if (!versionSegments.length) { log(`Could not match version from "${repoVersion}"`); return; } const versionNumber = versionMatch[0]; const parsedVersionNumber = parseFloat(versionNumber); const minimumVersionCheckPassed = minimumSegments.every( (n, i) => n <= (versionSegments[i] ?? 0), ); if (parsedVersionNumber >= MINIMUM_VERSION) return; if (minimumVersionCheckPassed) return; const warningMessage = `This extension requires GitLab version ${MINIMUM_VERSION} or later. Repo "${repo.name}" is currently using ${version}.`; const warningMessage = `This extension requires GitLab version ${MINIMUM_VERSION} or later. Repo "${repo.name}" is currently using ${repoVersion}.`; log(warningMessage); // if (!context.workspaceState.get(DO_NOT_SHOW_VERSION_WARNING)) { // const action = await vscode.window.showErrorMessage(warningMessage, DO_NOT_SHOW_AGAIN_TEXT); if (!context.workspaceState.get(DO_NOT_SHOW_VERSION_WARNING)) { const action = await vscode.window.showErrorMessage(warningMessage, DO_NOT_SHOW_AGAIN_TEXT); // if (action === DO_NOT_SHOW_AGAIN_TEXT) // await context.workspaceState.update(DO_NOT_SHOW_VERSION_WARNING, true); // } if (action === DO_NOT_SHOW_AGAIN_TEXT) await context.workspaceState.update(DO_NOT_SHOW_VERSION_WARNING, true); } }), ).catch(error => log(error)); }; Loading Loading
src/constants.ts +2 −1 Original line number Diff line number Diff line Loading @@ -7,4 +7,5 @@ export const DELETED = 'deleted'; export const RENAMED = 'renamed'; export const MODIFIED = 'modified'; export const DO_NOT_SHOW_VERSION_WARNING = 'DO_NOT_SHOW_VERSION_WARNING'; export const MINIMUM_VERSION = 13.5; // NOTE: This needs to _always_ be a 3 digits export const MINIMUM_VERSION = '13.5.0';
src/utils/check_version.test.ts +3 −2 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ describe('check_version', () => { ${'13.5.0'} ${'13.6.3'} ${'13.6.0-pre'} ${'13.6.0-pre-1'} ${'13.12.4'} ${'abc13.5def'} `('gets $version successfully', async ({ version }) => { Loading @@ -57,7 +58,7 @@ describe('check_version', () => { expect(vscode.window.showErrorMessage).not.toHaveBeenCalled(); }); xit(`shows warning when version is below 13.5`, async () => { it(`shows warning when version is below 13.5`, async () => { mockedRepositories = [createMockRepo(`13.4.2`)]; await getVersionForEachRepo(gitExtensionWrapper, context as vscode.ExtensionContext); Loading @@ -72,7 +73,7 @@ describe('check_version', () => { expect(logMock.log).toHaveBeenCalledWith(`Could not match version from "${BAD_VERSION}"`); }); xit('stores user preference for not showing the warning', async () => { it('stores user preference for not showing the warning', async () => { mockedRepositories = [createMockRepo('13.4')]; (vscode.window.showErrorMessage as jest.Mock).mockResolvedValue('Do not show again'); Loading
src/utils/check_version.ts +19 −13 Original line number Diff line number Diff line Loading @@ -8,31 +8,37 @@ export const getVersionForEachRepo = async ( context: vscode.ExtensionContext, ): Promise<void> => { const DO_NOT_SHOW_AGAIN_TEXT = 'Do not show again'; const toSegments = (version?: string) => { const match = version?.match(/\d+/g) || []; return match.map(Number); }; const minimumSegments = toSegments(MINIMUM_VERSION); await Promise.all( gitExtensionWrapper.repositories.map(async repo => { const version = await repo.getVersion(); const versionMatch = version?.match(/\d+\.\d+/); if (!versionMatch) { log(`Could not match version from "${version}"`); const repoVersion = await repo.getVersion(); const versionSegments = toSegments(repoVersion); if (!versionSegments.length) { log(`Could not match version from "${repoVersion}"`); return; } const versionNumber = versionMatch[0]; const parsedVersionNumber = parseFloat(versionNumber); const minimumVersionCheckPassed = minimumSegments.every( (n, i) => n <= (versionSegments[i] ?? 0), ); if (parsedVersionNumber >= MINIMUM_VERSION) return; if (minimumVersionCheckPassed) return; const warningMessage = `This extension requires GitLab version ${MINIMUM_VERSION} or later. Repo "${repo.name}" is currently using ${version}.`; const warningMessage = `This extension requires GitLab version ${MINIMUM_VERSION} or later. Repo "${repo.name}" is currently using ${repoVersion}.`; log(warningMessage); // if (!context.workspaceState.get(DO_NOT_SHOW_VERSION_WARNING)) { // const action = await vscode.window.showErrorMessage(warningMessage, DO_NOT_SHOW_AGAIN_TEXT); if (!context.workspaceState.get(DO_NOT_SHOW_VERSION_WARNING)) { const action = await vscode.window.showErrorMessage(warningMessage, DO_NOT_SHOW_AGAIN_TEXT); // if (action === DO_NOT_SHOW_AGAIN_TEXT) // await context.workspaceState.update(DO_NOT_SHOW_VERSION_WARNING, true); // } if (action === DO_NOT_SHOW_AGAIN_TEXT) await context.workspaceState.update(DO_NOT_SHOW_VERSION_WARNING, true); } }), ).catch(error => log(error)); }; Loading