@@ -10,15 +10,15 @@ import gql from 'graphql-tag';
10
10
import * as vscode from 'vscode' ;
11
11
import { Repository } from '../api/api' ;
12
12
import { 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' ;
14
14
import { commands } from '../common/executeCommands' ;
15
15
import { GitChangeType , InMemFileChange , SlimFileChange } from '../common/file' ;
16
16
import { GitHubRef } from '../common/githubRef' ;
17
17
import Logger from '../common/logger' ;
18
18
import { Remote } from '../common/remote' ;
19
19
import { ITelemetry } from '../common/telemetry' ;
20
20
import { 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' ;
22
22
import { formatError , isDescendant } from '../common/utils' ;
23
23
import { InMemFileChangeModel , RemoteFileChangeModel } from '../view/fileChangeModel' ;
24
24
import { OctokitCommon } from './common' ;
@@ -1333,47 +1333,32 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
1333
1333
return vscode . commands . executeCommand ( 'vscode.changes' , vscode . l10n . t ( 'Changes in Pull Request #{0}' , pullRequestModel . number ) , args ) ;
1334
1334
}
1335
1335
1336
- static async openCommitChanges ( folderManager : FolderRepositoryManager , commitSha : string ) {
1336
+ static async openCommitChanges ( githubRepository : GitHubRepository , commitSha : string ) {
1337
1337
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 ) {
1348
1340
vscode . window . showErrorMessage ( vscode . l10n . t ( 'Commit {0} has no parent' , commitSha . substring ( 0 , 7 ) ) ) ;
1349
1341
return ;
1350
1342
}
1351
- const parentSha = commit . parents [ 0 ] ;
1352
1343
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 ) {
1356
1346
vscode . window . showInformationMessage ( vscode . l10n . t ( 'No changes found in commit {0}' , commitSha . substring ( 0 , 7 ) ) ) ;
1357
1347
return ;
1358
1348
}
1359
1349
1360
1350
// Create URI pairs for the multi diff editor using review scheme
1361
1351
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 ) {
1372
1357
// For added files, show against empty
1373
1358
args . push ( [ rightUri , undefined , rightUri ] ) ;
1374
- } else if ( change . status === GitChangeType . DELETE ) {
1359
+ } else if ( changeType === GitChangeType . DELETE ) {
1375
1360
// For deleted files, show old version against empty
1376
- args . push ( [ rightPath , leftUri , undefined ] ) ;
1361
+ args . push ( [ rightUri , leftUri , undefined ] ) ;
1377
1362
} else {
1378
1363
args . push ( [ rightUri , leftUri , rightUri ] ) ;
1379
1364
}
@@ -1382,7 +1367,7 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
1382
1367
/* __GDPR__
1383
1368
"pr.openCommitChanges" : {}
1384
1369
*/
1385
- folderManager . telemetry . sendTelemetryEvent ( 'pr.openCommitChanges' ) ;
1370
+ githubRepository . telemetry . sendTelemetryEvent ( 'pr.openCommitChanges' ) ;
1386
1371
1387
1372
return commands . executeCommand ( 'vscode.changes' , vscode . l10n . t ( 'Changes in Commit {0}' , commitSha . substring ( 0 , 7 ) ) , args ) ;
1388
1373
} catch ( error ) {
0 commit comments