MCPcopy Index your code
hub / github.com/conwnet/github1s / getChangedFileDiffTitle

Function getChangedFileDiffTitle

extensions/github1s/src/changes/files.ts:104–125  ·  view source on GitHub ↗
(
	baseFileUri: vscode.Uri,
	headFileUri: vscode.Uri,
	status: adapterTypes.FileChangeStatus,
)

Source from the content-addressed store, hash-verified

102
103// get the title of the diff editor
104export const getChangedFileDiffTitle = (
105 baseFileUri: vscode.Uri,
106 headFileUri: vscode.Uri,
107 status: adapterTypes.FileChangeStatus,
108) => {
109 const baseFileName = basename(baseFileUri.path);
110 const headFileName = basename(headFileUri.path);
111 const [_repo, baseCommitSha] = baseFileUri.authority.split('+');
112 const [__repo, headCommitSha] = headFileUri.authority.split('+');
113 const baseFileLabel = `${baseFileName} (${baseCommitSha?.slice(0, 7)})`;
114 const headFileLabel = `${headFileName} (${headCommitSha?.slice(0, 7)})`;
115
116 if (status === adapterTypes.FileChangeStatus.Added) {
117 return `${headFileName} (added in ${headCommitSha?.slice(0, 7)})`;
118 }
119
120 if (status === adapterTypes.FileChangeStatus.Removed) {
121 return `${baseFileName} (deleted from ${baseCommitSha?.slice(0, 7)})`;
122 }
123
124 return `${baseFileLabel} ⟷ ${headFileLabel}`;
125};
126
127export const getChangedFileDiffCommand = (changedFile: VSCodeChangedFile): vscode.Command => {
128 let baseFileUri = changedFile.baseFileUri;

Callers 3

Calls 1

basenameFunction · 0.90

Tested by

no test coverage detected