MCPcopy
hub / github.com/conwnet/github1s / getConcreteFileUri

Function getConcreteFileUri

extensions/github1s/src/commands/editor.ts:71–80  ·  view source on GitHub ↗
(fileUri: vscode.Uri)

Source from the content-addressed store, hash-verified

69// get the file uri with the concrete commit sha, the `ref` in
70// `fileUri.authority` maybe newer but not related this file
71const getConcreteFileUri = async (fileUri: vscode.Uri) => {
72 // the `fileUri.authority` maybe empty, fallback to router.getAuthority() in this case
73 const fileAuthority = fileUri.authority || (await router.getAuthority());
74 const [repo, ref] = fileAuthority.split('+').filter(Boolean);
75 const repository = Repository.getInstance(fileUri.scheme, repo);
76 const commit = await repository.getFileLatestCommit(ref, fileUri.path.slice(1));
77 const latestCommitSha = commit?.sha || (await repository.getCommitItem(ref))?.sha || 'HEAD';
78
79 return fileUri.with({ authority: `${repo}+${latestCommitSha}` });
80};
81
82// show the file's diff between current commit and previous commit
83const commandOpenFilePreviousRevision = async (fileUri: vscode.Uri) => {

Callers 2

Calls 4

getAuthorityMethod · 0.80
getFileLatestCommitMethod · 0.80
getCommitItemMethod · 0.80
getInstanceMethod · 0.45

Tested by

no test coverage detected