@@ -10,15 +10,15 @@ import gql from 'graphql-tag';
1010import * as vscode from 'vscode' ;
1111import { Repository } from '../api/api' ;
1212import { COPILOT_ACCOUNTS , DiffSide , IComment , IReviewThread , SubjectType , ViewedState } from '../common/comment' ;
13- import { getModifiedContentFromDiffHunk , parseDiff } from '../common/diffHunk' ;
13+ import { getGitChangeType , getModifiedContentFromDiffHunk , parseDiff } from '../common/diffHunk' ;
1414import { commands } from '../common/executeCommands' ;
1515import { GitChangeType , InMemFileChange , SlimFileChange } from '../common/file' ;
1616import { GitHubRef } from '../common/githubRef' ;
1717import Logger from '../common/logger' ;
1818import { Remote } from '../common/remote' ;
1919import { ITelemetry } from '../common/telemetry' ;
2020import { ClosedEvent , EventType , ReviewEvent , TimelineEvent } from '../common/timelineEvent' ;
21- import { resolvePath , reviewPath , Schemes , toPRUri , toReviewUri } from '../common/uri' ;
21+ import { resolvePath , Schemes , toGitHubCommitUri , toPRUri , toReviewUri } from '../common/uri' ;
2222import { formatError , isDescendant } from '../common/utils' ;
2323import { InMemFileChangeModel , RemoteFileChangeModel } from '../view/fileChangeModel' ;
2424import { OctokitCommon } from './common' ;
@@ -1333,47 +1333,32 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
13331333 return vscode . commands . executeCommand ( 'vscode.changes' , vscode . l10n . t ( 'Changes in Pull Request #{0}' , pullRequestModel . number ) , args ) ;
13341334 }
13351335
1336- static async openCommitChanges ( folderManager : FolderRepositoryManager , commitSha : string ) {
1336+ static async openCommitChanges ( githubRepository : GitHubRepository , commitSha : string ) {
13371337 try {
1338- // Get the repository from the folder manager
1339- const repository = folderManager . repository ;
1340- if ( ! repository ) {
1341- vscode . window . showErrorMessage ( vscode . l10n . t ( 'No repository found' ) ) ;
1342- return ;
1343- }
1344-
1345- // Get the commit to find its parent
1346- const commit = await repository . getCommit ( commitSha ) ;
1347- if ( ! commit . parents || commit . parents . length === 0 ) {
1338+ const parentCommit = await githubRepository . getCommitParent ( commitSha ) ;
1339+ if ( ! parentCommit ) {
13481340 vscode . window . showErrorMessage ( vscode . l10n . t ( 'Commit {0} has no parent' , commitSha . substring ( 0 , 7 ) ) ) ;
13491341 return ;
13501342 }
1351- const parentSha = commit . parents [ 0 ] ;
13521343
1353- // Get the changes between the commit and its parent
1354- const changes = await repository . diffBetween ( parentSha , commitSha ) ;
1355- if ( ! changes || changes . length === 0 ) {
1344+ const changes = await githubRepository . compareCommits ( parentCommit , commitSha ) ;
1345+ if ( ! changes ?. files || changes . files . length === 0 ) {
13561346 vscode . window . showInformationMessage ( vscode . l10n . t ( 'No changes found in commit {0}' , commitSha . substring ( 0 , 7 ) ) ) ;
13571347 return ;
13581348 }
13591349
13601350 // Create URI pairs for the multi diff editor using review scheme
13611351 const args : [ vscode . Uri , vscode . Uri | undefined , vscode . Uri | undefined ] [ ] = [ ] ;
1362- for ( const change of changes ) {
1363- const rightRelativePath = path . relative ( repository . rootUri . fsPath , change . uri . fsPath ) ;
1364- const rightPath = reviewPath ( rightRelativePath , commitSha ) ;
1365- let rightUri = toReviewUri ( rightPath , rightRelativePath , undefined , commitSha , false , { base : false } , repository . rootUri ) ;
1366-
1367- const leftRelativePath = path . relative ( repository . rootUri . fsPath , change . originalUri . fsPath ) ;
1368- const leftPath = reviewPath ( leftRelativePath , parentSha ) ;
1369- let leftUri = toReviewUri ( leftPath , ( change . status === GitChangeType . RENAME ) ? path . relative ( repository . rootUri . fsPath , change . originalUri . fsPath ) : leftRelativePath , undefined , parentSha , false , { base : true } , repository . rootUri ) ;
1370-
1371- if ( change . status === GitChangeType . ADD ) {
1352+ for ( const change of changes . files ) {
1353+ const rightUri = toGitHubCommitUri ( change . filename , { commit : commitSha , owner : githubRepository . remote . owner , repo : githubRepository . remote . repositoryName } ) ;
1354+ const leftUri = toGitHubCommitUri ( change . previous_filename ?? change . filename , { commit : parentCommit , owner : githubRepository . remote . owner , repo : githubRepository . remote . repositoryName } ) ;
1355+ const changeType = getGitChangeType ( change . status ) ;
1356+ if ( changeType === GitChangeType . ADD ) {
13721357 // For added files, show against empty
13731358 args . push ( [ rightUri , undefined , rightUri ] ) ;
1374- } else if ( change . status === GitChangeType . DELETE ) {
1359+ } else if ( changeType === GitChangeType . DELETE ) {
13751360 // For deleted files, show old version against empty
1376- args . push ( [ rightPath , leftUri , undefined ] ) ;
1361+ args . push ( [ rightUri , leftUri , undefined ] ) ;
13771362 } else {
13781363 args . push ( [ rightUri , leftUri , rightUri ] ) ;
13791364 }
@@ -1382,7 +1367,7 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
13821367 /* __GDPR__
13831368 "pr.openCommitChanges" : {}
13841369 */
1385- folderManager . telemetry . sendTelemetryEvent ( 'pr.openCommitChanges' ) ;
1370+ githubRepository . telemetry . sendTelemetryEvent ( 'pr.openCommitChanges' ) ;
13861371
13871372 return commands . executeCommand ( 'vscode.changes' , vscode . l10n . t ( 'Changes in Commit {0}' , commitSha . substring ( 0 , 7 ) ) , args ) ;
13881373 } catch ( error ) {
0 commit comments