Loading src/common/__mocks__/fetch_logged.ts +3 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,9 @@ const DEFAULT_JSON_RESPONSE = { const fn = jest.fn().mockResolvedValue({ ok: true, async arrayBuffer() { return Buffer.from(DEFAULT_FETCH_RESPONSE); }, async text() { return DEFAULT_FETCH_RESPONSE; }, Loading src/desktop/command_names.ts +0 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,6 @@ export const USER_COMMANDS = { */ export const PROGRAMMATIC_COMMANDS = { SHOW_RICH_CONTENT: 'gl.showRichContent', NO_IMAGE_REVIEW: 'gl.noImageReview', }; export const VS_COMMANDS = { Loading src/desktop/commands/mr_discussion_commands.test.ts +1 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,7 @@ describe('MR discussion commands', () => { const createVsThread = (filePath: string, fileCommit: string, lineNumber: number) => { const uri = toReviewUri({ path: filePath, exists: true, commit: fileCommit, repositoryRoot: 'root', projectId: mr.project_id, Loading src/desktop/extension.ts +6 −4 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ import { issuableDataProvider } from './tree_view/issuable_data_provider'; import { currentBranchDataProvider } from './tree_view/current_branch_data_provider'; import { initializeLogging } from '../common/log'; import { handleError } from '../common/errors/handle_error'; import { GitContentProvider } from './review/git_content_provider'; import { ReviewFileSystem } from './review/review_file_system'; import { GqlSecurityFinding } from './gitlab/security_findings/api/get_security_finding_report'; import { ProjectInRepository } from './gitlab/new_project'; import { Loading Loading @@ -179,8 +179,6 @@ const registerCommands = (context: vscode.ExtensionContext) => { [USER_COMMANDS.CANCEL_JOB]: cancelJob, [USER_COMMANDS.RETRY_FAILED_PIPELINE_JOBS]: retryPipeline, [USER_COMMANDS.CANCEL_PIPELINE]: cancelPipeline, [PROGRAMMATIC_COMMANDS.NO_IMAGE_REVIEW]: () => vscode.window.showInformationMessage("GitLab MR review doesn't support images yet."), }; Object.keys(commands).forEach(cmd => { Loading Loading @@ -221,7 +219,11 @@ export const activate = async (context: vscode.ExtensionContext) => { const outputChannel = vscode.window.createOutputChannel('GitLab Workflow'); initializeLogging(line => outputChannel.appendLine(line)); vscode.workspace.registerTextDocumentContentProvider(REVIEW_URI_SCHEME, new GitContentProvider()); vscode.workspace.registerFileSystemProvider( REVIEW_URI_SCHEME, new ReviewFileSystem(), ReviewFileSystem.OPTIONS, ); vscode.workspace.registerTextDocumentContentProvider( MERGED_YAML_URI_SCHEME, new MergedYamlContentProvider(), Loading src/desktop/git/get_file_content.ts +23 −4 Original line number Diff line number Diff line import { join } from 'path'; import { Repository } from '../api/git'; // even on Windows, the git show command accepts only POSIX paths const getAbsolutePath = (rawRepository: Repository, path: string) => join(rawRepository.rootUri.fsPath, path).replace(/\\/g, '/'); export const getFileContent = ( rawRepository: Repository, path: string, sha: string, ): Promise<string | null> => { // even on Windows, the git show command accepts only POSIX paths const absolutePath = join(rawRepository.rootUri.fsPath, path).replace(/\\/g, '/'); ): Promise<Buffer | null> => { const absolutePath = getAbsolutePath(rawRepository, path); // null sufficiently signalises that the file has not been found // this scenario is going to happen often (for open and squashed MRs) return rawRepository.buffer(sha, absolutePath).catch(() => null); }; export const getFileSize = async ( rawRepository: Repository, path: string, sha: string, ): Promise<number | null> => { const absolutePath = getAbsolutePath(rawRepository, path); try { const details = await rawRepository.getObjectDetails(sha, absolutePath); return details.size; } catch { // null sufficiently signalises that the file has not been found // this scenario is going to happen often (for open and squashed MRs) return rawRepository.show(sha, absolutePath).catch(() => null); return null; } }; Loading
src/common/__mocks__/fetch_logged.ts +3 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,9 @@ const DEFAULT_JSON_RESPONSE = { const fn = jest.fn().mockResolvedValue({ ok: true, async arrayBuffer() { return Buffer.from(DEFAULT_FETCH_RESPONSE); }, async text() { return DEFAULT_FETCH_RESPONSE; }, Loading
src/desktop/command_names.ts +0 −1 Original line number Diff line number Diff line Loading @@ -66,7 +66,6 @@ export const USER_COMMANDS = { */ export const PROGRAMMATIC_COMMANDS = { SHOW_RICH_CONTENT: 'gl.showRichContent', NO_IMAGE_REVIEW: 'gl.noImageReview', }; export const VS_COMMANDS = { Loading
src/desktop/commands/mr_discussion_commands.test.ts +1 −0 Original line number Diff line number Diff line Loading @@ -121,6 +121,7 @@ describe('MR discussion commands', () => { const createVsThread = (filePath: string, fileCommit: string, lineNumber: number) => { const uri = toReviewUri({ path: filePath, exists: true, commit: fileCommit, repositoryRoot: 'root', projectId: mr.project_id, Loading
src/desktop/extension.ts +6 −4 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ import { issuableDataProvider } from './tree_view/issuable_data_provider'; import { currentBranchDataProvider } from './tree_view/current_branch_data_provider'; import { initializeLogging } from '../common/log'; import { handleError } from '../common/errors/handle_error'; import { GitContentProvider } from './review/git_content_provider'; import { ReviewFileSystem } from './review/review_file_system'; import { GqlSecurityFinding } from './gitlab/security_findings/api/get_security_finding_report'; import { ProjectInRepository } from './gitlab/new_project'; import { Loading Loading @@ -179,8 +179,6 @@ const registerCommands = (context: vscode.ExtensionContext) => { [USER_COMMANDS.CANCEL_JOB]: cancelJob, [USER_COMMANDS.RETRY_FAILED_PIPELINE_JOBS]: retryPipeline, [USER_COMMANDS.CANCEL_PIPELINE]: cancelPipeline, [PROGRAMMATIC_COMMANDS.NO_IMAGE_REVIEW]: () => vscode.window.showInformationMessage("GitLab MR review doesn't support images yet."), }; Object.keys(commands).forEach(cmd => { Loading Loading @@ -221,7 +219,11 @@ export const activate = async (context: vscode.ExtensionContext) => { const outputChannel = vscode.window.createOutputChannel('GitLab Workflow'); initializeLogging(line => outputChannel.appendLine(line)); vscode.workspace.registerTextDocumentContentProvider(REVIEW_URI_SCHEME, new GitContentProvider()); vscode.workspace.registerFileSystemProvider( REVIEW_URI_SCHEME, new ReviewFileSystem(), ReviewFileSystem.OPTIONS, ); vscode.workspace.registerTextDocumentContentProvider( MERGED_YAML_URI_SCHEME, new MergedYamlContentProvider(), Loading
src/desktop/git/get_file_content.ts +23 −4 Original line number Diff line number Diff line import { join } from 'path'; import { Repository } from '../api/git'; // even on Windows, the git show command accepts only POSIX paths const getAbsolutePath = (rawRepository: Repository, path: string) => join(rawRepository.rootUri.fsPath, path).replace(/\\/g, '/'); export const getFileContent = ( rawRepository: Repository, path: string, sha: string, ): Promise<string | null> => { // even on Windows, the git show command accepts only POSIX paths const absolutePath = join(rawRepository.rootUri.fsPath, path).replace(/\\/g, '/'); ): Promise<Buffer | null> => { const absolutePath = getAbsolutePath(rawRepository, path); // null sufficiently signalises that the file has not been found // this scenario is going to happen often (for open and squashed MRs) return rawRepository.buffer(sha, absolutePath).catch(() => null); }; export const getFileSize = async ( rawRepository: Repository, path: string, sha: string, ): Promise<number | null> => { const absolutePath = getAbsolutePath(rawRepository, path); try { const details = await rawRepository.getObjectDetails(sha, absolutePath); return details.size; } catch { // null sufficiently signalises that the file has not been found // this scenario is going to happen often (for open and squashed MRs) return rawRepository.show(sha, absolutePath).catch(() => null); return null; } };