Skip to content

Commit a80e822

Browse files
authored
Pull request diff shows outdated diff (#6931)
Fixes #6889
1 parent 45a6f08 commit a80e822

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/view/gitHubContentProvider.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export abstract class ChangesContentProvider implements Partial<vscode.FileSyste
5959
return { dispose: () => { } };
6060
}
6161

62-
stat(_uri: any): vscode.FileStat {
62+
async stat(_uri: any): Promise<vscode.FileStat> {
6363
// const params = fromGitHubURI(uri);
6464

6565
return {
@@ -141,6 +141,28 @@ export class GitContentProvider extends ChangesContentProvider implements vscode
141141
super();
142142
}
143143

144+
override async stat(uri: vscode.Uri): Promise<vscode.FileStat> {
145+
let mtime = 0;
146+
const params = fromGitHubURI(uri);
147+
if (params?.branch) {
148+
const branch = await this.folderRepositoryManager.repository.getBranch(params?.branch);
149+
if (branch.commit) {
150+
const commit = await this.folderRepositoryManager.repository.getCommit(branch.commit);
151+
if (commit) {
152+
mtime = commit.commitDate?.getTime() ?? 0;
153+
}
154+
}
155+
156+
}
157+
return {
158+
type: vscode.FileType.File,
159+
ctime: 0,
160+
mtime: mtime,
161+
size: 0,
162+
permissions: vscode.FilePermission.Readonly
163+
};
164+
}
165+
144166
async readFile(uri: vscode.Uri): Promise<Uint8Array> {
145167
const params = fromGitHubURI(uri);
146168
if (!params || params.isEmpty) {

0 commit comments

Comments
 (0)