Browse Source

Fixes get working file & file commit quickpick nav

Adds GitService.getWorkingUri
Removes WorkspaceFileExistsRequestType from vsls protocol
main
Eric Amodio 5 years ago
parent
commit
c5f510ecbd
14 changed files with 108 additions and 365 deletions
  1. +7
    -2
      src/commands/diffLineWithWorking.ts
  2. +3
    -5
      src/commands/diffWithWorking.ts
  3. +3
    -6
      src/commands/openWorkingFile.ts
  4. +0
    -7
      src/commands/showQuickCommitDetails.ts
  5. +0
    -11
      src/commands/showQuickCommitFileDetails.ts
  6. +40
    -139
      src/git/gitService.ts
  7. +7
    -13
      src/git/models/commit.ts
  8. +39
    -106
      src/quickpicks/commitFileQuickPick.ts
  9. +0
    -2
      src/quickpicks/commitQuickPick.ts
  10. +4
    -7
      src/quickpicks/fileHistoryQuickPick.ts
  11. +3
    -8
      src/views/nodes/fileHistoryTrackerNode.ts
  12. +1
    -22
      src/vsls/guest.ts
  13. +1
    -23
      src/vsls/host.ts
  14. +0
    -14
      src/vsls/protocol.ts

+ 7
- 2
src/commands/diffLineWithWorking.ts View File

@ -1,5 +1,5 @@
'use strict';
import { commands, TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import { commands, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
import { Container } from '../container';
import { GitCommit, GitService, GitUri } from '../git/gitService';
import { Logger } from '../logger';
@ -69,6 +69,11 @@ export class DiffLineWithWorkingCommand extends ActiveEditorCommand {
}
}
const workingUri = await args.commit.getWorkingUri();
if (workingUri === undefined) {
return window.showWarningMessage('Unable to open compare. File has been deleted from the working tree');
}
const diffArgs: DiffWithCommandArgs = {
repoPath: args.commit.repoPath,
lhs: {
@ -77,7 +82,7 @@ export class DiffLineWithWorkingCommand extends ActiveEditorCommand {
},
rhs: {
sha: '',
uri: args.commit.workingUri
uri: workingUri
},
line: args.line,
showOptions: args.showOptions

+ 3
- 5
src/commands/diffWithWorking.ts View File

@ -117,13 +117,11 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
}
}
const [workingFileName] = await Container.git.findWorkingFileName(gitUri.fsPath, gitUri.repoPath);
if (workingFileName === undefined) {
const workingUri = await args.commit.getWorkingUri();
if (workingUri === undefined) {
return window.showWarningMessage('Unable to open compare. File has been deleted from the working tree');
}
args.commit.workingFileName = workingFileName;
const diffArgs: DiffWithCommandArgs = {
repoPath: args.commit.repoPath,
lhs: {
@ -132,7 +130,7 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
},
rhs: {
sha: '',
uri: args.commit.workingUri
uri: workingUri
},
line: args.line,
showOptions: args.showOptions

+ 3
- 6
src/commands/openWorkingFile.ts View File

@ -33,17 +33,14 @@ export class OpenWorkingFileCommand extends ActiveEditorCommand {
args.uri = await GitUri.fromUri(uri);
if (args.uri instanceof GitUri && args.uri.sha) {
const [fileName, repoPath] = await Container.git.findWorkingFileName(
args.uri.fsPath,
args.uri.repoPath
);
if (fileName === undefined) {
const workingUri = await Container.git.getWorkingUri(args.uri.repoPath!, args.uri);
if (workingUri === undefined) {
return window.showWarningMessage(
'Unable to open working file. File could not be found in the working tree'
);
}
args.uri = new GitUri(GitUri.resolveToUri(fileName, repoPath), repoPath);
args.uri = new GitUri(workingUri, args.uri.repoPath);
}
}

+ 0
- 7
src/commands/showQuickCommitDetails.ts View File

@ -1,5 +1,4 @@
'use strict';
import * as paths from 'path';
import { commands, TextEditor, Uri } from 'vscode';
import { GlyphChars } from '../constants';
import { Container } from '../container';
@ -68,7 +67,6 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
const gitUri = await GitUri.fromUri(uri);
let repoPath = gitUri.repoPath;
let workingFileName = repoPath ? paths.relative(repoPath, gitUri.fsPath) : gitUri.fsPath;
args = { ...args };
if (args.sha === undefined) {
@ -90,7 +88,6 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
args.sha = blame.commit.sha;
repoPath = blame.commit.repoPath;
workingFileName = blame.commit.fileName;
args.commit = blame.commit;
}
@ -124,10 +121,6 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
return Messages.showCommitNotFoundWarningMessage('Unable to show commit details');
}
if (args.commit.workingFileName === undefined) {
args.commit.workingFileName = workingFileName;
}
if (args.showInView) {
void (await Container.searchView.search(repoPath!, args.commit.sha, GitRepoSearchBy.Sha, {
label: { label: `commits with an id matching '${args.commit.shortSha}'` }

+ 0
- 11
src/commands/showQuickCommitFileDetails.ts View File

@ -66,8 +66,6 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
uri = getCommandUri(uri, editor);
if (uri == null) return undefined;
let workingFileName = args.commit && args.commit.workingFileName;
const gitUri = await GitUri.fromUri(uri);
args = { ...args };
@ -91,7 +89,6 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
args.sha = blame.commit.sha;
args.commit = blame.commit;
workingFileName = paths.relative(args.commit.repoPath, gitUri.fsPath);
}
catch (ex) {
Logger.error(ex, 'ShowQuickCommitFileDetailsCommand', `getBlameForLine(${blameline})`);
@ -103,10 +100,6 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
try {
if (args.commit === undefined || !args.commit.isFile) {
if (args.commit !== undefined) {
workingFileName = undefined;
}
if (args.fileLog !== undefined) {
args.commit = args.fileLog.commits.get(args.sha!);
// If we can't find the commit, kill the fileLog
@ -128,10 +121,6 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
return Messages.showCommitNotFoundWarningMessage('Unable to show commit file details');
}
// Attempt to the most recent commit -- so that we can find the real working filename if there was a rename
args.commit.workingFileName = workingFileName;
[args.commit.workingFileName] = await Container.git.findWorkingFileName(args.commit);
const shortSha = GitService.shortenSha(args.sha!);
if (args.goBackCommand === undefined) {

+ 40
- 139
src/git/gitService.ts View File

@ -39,7 +39,6 @@ import {
GitBlameParser,
GitBranch,
GitBranchParser,
GitCommit,
GitCommitType,
GitContributor,
GitDiff,
@ -582,136 +581,6 @@ export class GitService implements Disposable {
);
}
async fileExists(
repoPath: string,
fileName: string,
options: { ensureCase: boolean } = { ensureCase: false }
): Promise<boolean> {
if (Container.vsls.isMaybeGuest) {
const guest = await Container.vsls.guest();
if (guest !== undefined) {
return guest.fileExists(repoPath, fileName, options);
}
}
const path = paths.resolve(repoPath, fileName);
const exists = await new Promise<boolean>((resolve, reject) => fs.exists(path, resolve));
if (!options.ensureCase || !exists) return exists;
// Deal with renames in case only on case-insensative file systems
const normalizedRepoPath = paths.normalize(repoPath);
return this.fileExistsWithCase(path, normalizedRepoPath, normalizedRepoPath.length);
}
private async fileExistsWithCase(path: string, repoPath: string, repoPathLength: number): Promise<boolean> {
const dir = paths.dirname(path);
if (dir.length < repoPathLength) return false;
if (dir === repoPath) return true;
const filenames = await new Promise<string[]>((resolve, reject) =>
fs.readdir(dir, (err: NodeJS.ErrnoException, files: string[]) => {
if (err) {
reject(err);
}
else {
resolve(files);
}
})
);
if (filenames.indexOf(paths.basename(path)) === -1) {
return false;
}
return this.fileExistsWithCase(dir, repoPath, repoPathLength);
}
@log()
async findNextCommit(repoPath: string, fileName: string, ref?: string): Promise<GitLogCommit | undefined> {
let log = await this.getLogForFile(repoPath, fileName, { maxCount: 1, ref: ref, renames: true, reverse: true });
let commit = log && Iterables.first(log.commits.values());
if (commit) return commit;
const nextFileName = await this.findNextFileName(repoPath, fileName, ref);
if (nextFileName) {
log = await this.getLogForFile(repoPath, nextFileName, {
maxCount: 1,
ref: ref,
renames: true,
reverse: true
});
commit = log && Iterables.first(log.commits.values());
}
return commit;
}
@log()
async findNextFileName(repoPath: string | undefined, fileName: string, ref?: string): Promise<string | undefined> {
[fileName, repoPath] = Git.splitPath(fileName, repoPath);
return (await this.fileExists(repoPath, fileName, { ensureCase: true }))
? fileName
: this.findNextFileNameCore(repoPath, fileName, ref);
}
private async findNextFileNameCore(repoPath: string, fileName: string, ref?: string): Promise<string | undefined> {
if (ref === undefined) {
// Get the most recent commit for this file name
ref = await this.getRecentShaForFile(repoPath, fileName);
if (ref === undefined) return undefined;
}
// Get the full commit (so we can see if there are any matching renames in the files)
const log = await this.getLog(repoPath, { maxCount: 1, ref: ref });
if (log === undefined) return undefined;
const c = Iterables.first(log.commits.values());
const file = c.files.find(f => f.originalFileName === fileName);
if (file === undefined) return undefined;
return file.fileName;
}
async findWorkingFileName(commit: GitCommit): Promise<[string | undefined, string | undefined]>;
async findWorkingFileName(
fileName: string,
repoPath?: string,
ref?: string
): Promise<[string | undefined, string | undefined]>;
@log()
async findWorkingFileName(
commitOrFileName: GitCommit | string,
repoPath?: string,
ref?: string
): Promise<[string | undefined, string | undefined]> {
let fileName;
if (typeof commitOrFileName === 'string') {
fileName = commitOrFileName;
if (repoPath === undefined) {
repoPath = await this.getRepoPath(fileName, { ref: ref });
[fileName, repoPath] = Git.splitPath(fileName, repoPath);
}
else {
fileName = Strings.normalizePath(paths.relative(repoPath, fileName));
}
}
else {
const c = commitOrFileName;
repoPath = c.repoPath;
if (c.workingFileName && (await this.fileExists(repoPath, c.workingFileName, { ensureCase: true }))) {
return [c.workingFileName, repoPath];
}
fileName = c.fileName;
}
// Keep walking up to the most recent commit for a given filename, until it exists on disk
while (true) {
if (await this.fileExists(repoPath, fileName, { ensureCase: true })) return [fileName, repoPath];
fileName = await this.findNextFileNameCore(repoPath, fileName);
if (fileName === undefined) return [undefined, undefined];
}
}
@log({
args: {
0: (editor: TextEditor) =>
@ -1360,13 +1229,6 @@ export class GitService implements Disposable {
}
@log()
getRecentShaForFile(repoPath: string, fileName: string) {
return Git.log_recent(repoPath, fileName, {
similarityThreshold: Container.config.advanced.similarityThreshold
});
}
@log()
async getLogCommit(repoPath: string, ref: string): Promise<GitLogCommit | undefined> {
const log = await this.getLog(repoPath, { maxCount: 2, ref: ref });
if (log === undefined) return undefined;
@ -2255,7 +2117,8 @@ export class GitService implements Disposable {
if (ref === GitService.deletedOrMissingSha) return undefined;
if (!ref || (Git.isUncommitted(ref) && !Git.isStagedUncommitted(ref))) {
if (await this.fileExists(repoPath!, fileName)) return GitUri.file(fileName);
const data = await Git.ls_files(repoPath!, fileName);
if (data !== undefined) return GitUri.file(fileName);
return undefined;
}
@ -2267,6 +2130,44 @@ export class GitService implements Disposable {
return GitUri.toRevisionUri(ref, fileName, repoPath!);
}
@log()
async getWorkingUri(repoPath: string, uri: Uri) {
let fileName = GitUri.getRelativePath(uri, repoPath);
let data;
let ref;
do {
data = await Git.ls_files(repoPath, fileName);
if (data !== undefined) {
return GitUri.resolveToUri(data, repoPath);
}
// Get the most recent commit for this file name
ref = await Git.log_recent(repoPath, fileName, {
similarityThreshold: Container.config.advanced.similarityThreshold
});
if (ref === undefined) return undefined;
// Now check if that commit had any renames
data = await Git.log_file(repoPath, '.', ref, {
filters: ['R'],
format: GitLogParser.simpleFormat,
maxCount: 1
});
if (data == null || data.length === 0) {
return GitUri.resolveToUri(fileName, repoPath);
}
const [renamedRef, renamedFile] = GitLogParser.parseSimpleRenamed(data, fileName);
if (renamedRef === undefined || renamedFile === undefined) {
return GitUri.resolveToUri(fileName, repoPath);
}
ref = renamedRef;
fileName = renamedFile;
} while (true);
}
isTrackable(scheme: string): boolean;
isTrackable(uri: Uri): boolean;
isTrackable(schemeOruri: string | Uri): boolean {

+ 7
- 13
src/git/models/commit.ts View File

@ -45,7 +45,6 @@ export abstract class GitCommit {
readonly type: GitCommitType;
readonly originalFileName: string | undefined;
previousFileName: string | undefined;
workingFileName?: string;
protected readonly _fileName: string;
protected _previousSha: string | undefined;
@ -154,8 +153,13 @@ export abstract class GitCommit {
return GitUri.resolveToUri(this.fileName, this.repoPath);
}
get workingUri(): Uri {
return this.workingFileName ? GitUri.resolveToUri(this.workingFileName, this.repoPath) : this.uri;
private _workingUriPromise: Promise<Uri | undefined> | undefined;
getWorkingUri(): Promise<Uri | undefined> | undefined {
if (this._workingUriPromise === undefined) {
this._workingUriPromise = Container.git.getWorkingUri(this.repoPath, this.uri);
}
return this._workingUriPromise;
}
private get authorDateFormatter(): Dates.DateFormatter {
@ -227,16 +231,6 @@ export abstract class GitCommit {
return CommitFormatter.fromTemplate('${message}', this, { truncateMessageAtNewLine: true });
}
async resolvePreviousFileSha(): Promise<void> {
if (this._resolvedPreviousFileSha !== undefined) return;
this._resolvedPreviousFileSha = await Container.git.resolveReference(
this.repoPath,
this.previousFileSha,
this.fileName ? this.previousUri : undefined
);
}
toGitUri(previous: boolean = false): GitUri {
return GitUri.fromCommit(this, previous);
}

+ 39
- 106
src/quickpicks/commitFileQuickPick.ts View File

@ -16,7 +16,7 @@ import { GlyphChars } from '../constants';
import { Container } from '../container';
import { GitLog, GitLogCommit, GitUri, RemoteResourceType } from '../git/gitService';
import { KeyCommand, KeyNoopCommand } from '../keyboard';
import { Iterables, Strings } from '../system';
import { Strings } from '../system';
import {
CommandQuickPickItem,
getQuickPickIgnoreFocusOut,
@ -100,9 +100,6 @@ export class CommitFileQuickPick {
const stash = commit.isStash;
const workingName =
(commit.workingFileName && paths.basename(commit.workingFileName)) || paths.basename(commit.fileName);
const isUncommitted = commit.isUncommitted;
if (isUncommitted) {
// Since we can't trust the previous sha on an uncommitted commit, find the last commit for this file
@ -112,7 +109,7 @@ export class CommitFileQuickPick {
commit = c;
}
await commit.resolvePreviousFileSha();
const workingUri = await commit.getWorkingUri();
if (stash) {
items.push(new ApplyCommitFileChangesCommandQuickPickItem(commit));
@ -136,7 +133,7 @@ export class CommitFileQuickPick {
);
}
if (commit.workingFileName) {
if (workingUri) {
const commandArgs: DiffWithWorkingCommandArgs = {
commit: commit
};
@ -146,22 +143,25 @@ export class CommitFileQuickPick {
label: '$(git-compare) Open Changes with Working File',
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} $(git-commit) ${commit.shortSha} ${
GlyphChars.Space
} $(git-compare) ${GlyphChars.Space} $(file-text) ${workingName}`
} $(git-compare) ${GlyphChars.Space} $(file-text) ${GitUri.getRelativePath(
workingUri,
commit.repoPath
)}`
},
Commands.DiffWithWorking,
[GitUri.resolveToUri(commit.workingFileName, commit.repoPath), commandArgs]
[workingUri, commandArgs]
)
);
}
if (commit.workingFileName && commit.status !== 'D') {
if (workingUri && commit.status !== 'D') {
items.push(new OpenCommitFileCommandQuickPickItem(commit));
}
items.push(new OpenCommitFileRevisionCommandQuickPickItem(commit));
const remotes = await Container.git.getRemotes(commit.repoPath);
if (remotes.length) {
if (commit.workingFileName && commit.status !== 'D') {
if (workingUri && commit.status !== 'D') {
const branch = await Container.git.getBranch(commit.repoPath);
if (branch !== undefined) {
items.push(
@ -169,7 +169,7 @@ export class CommitFileQuickPick {
remotes,
{
type: RemoteResourceType.File,
fileName: commit.workingFileName,
fileName: paths.basename(workingUri.fsPath),
branch: branch.name
},
currentCommand
@ -226,7 +226,7 @@ export class CommitFileQuickPick {
);
}
if (commit.workingFileName) {
if (workingUri) {
const commandArgs: ShowQuickFileHistoryCommandArgs = {
log: fileLog,
goBackCommand: currentCommand
@ -238,7 +238,7 @@ export class CommitFileQuickPick {
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} of ${paths.basename(commit.fileName)}`
},
Commands.ShowQuickFileHistory,
[GitUri.resolveToUri(commit.workingFileName, commit.repoPath), commandArgs]
[workingUri, commandArgs]
)
);
}
@ -250,7 +250,9 @@ export class CommitFileQuickPick {
items.push(
new CommandQuickPickItem(
{
label: `$(history) Show ${commit.workingFileName ? 'Previous ' : ''}File History`,
label: `$(history) Show ${
GitUri.getRelativePath(workingUri || commit.uri, commit.repoPath) ? 'Previous ' : ''
}File History`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} of ${paths.basename(
commit.fileName
)} ${Strings.pad(GlyphChars.Dot, 1, 1)} from ${GlyphChars.Space}$(git-commit) ${
@ -286,105 +288,36 @@ export class CommitFileQuickPick {
let previousCommand: KeyCommand | (() => Promise<KeyCommand>) | undefined = undefined;
let nextCommand: KeyCommand | (() => Promise<KeyCommand>) | undefined = undefined;
if (!stash) {
// If we have the full history, we are good
if (fileLog !== undefined && !fileLog.truncated && fileLog.sha === undefined) {
previousCommand = async () => {
const previousUri = await Container.git.getPreviousUri(commit.repoPath, uri, commit.sha);
if (previousUri === undefined || previousUri.sha === undefined) return KeyNoopCommand;
const previousCommandArgs: ShowQuickCommitFileDetailsCommandArgs = {
fileLog: fileLog,
sha: commit.previousSha,
// If we have the full file history, reuse it
fileLog:
fileLog !== undefined && !fileLog.truncated && fileLog.sha === undefined ? fileLog : undefined,
sha: previousUri.sha,
goBackCommand: goBackCommand
};
previousCommand =
commit.previousSha === undefined
? undefined
: new KeyCommandQuickPickItem(Commands.ShowQuickCommitFileDetails, [
commit.previousUri,
previousCommandArgs
]);
return new KeyCommandQuickPickItem(Commands.ShowQuickCommitFileDetails, [
previousUri,
previousCommandArgs
]);
};
nextCommand = async () => {
const nextUri = await Container.git.getNextUri(commit.repoPath, uri, commit.sha);
if (nextUri === undefined || nextUri.sha === undefined) return KeyNoopCommand;
const nextCommandArgs: ShowQuickCommitFileDetailsCommandArgs = {
fileLog: fileLog,
sha: commit.nextSha,
// If we have the full file history, reuse it
fileLog:
fileLog !== undefined && !fileLog.truncated && fileLog.sha === undefined ? fileLog : undefined,
sha: nextUri.sha,
goBackCommand: goBackCommand
};
nextCommand =
commit.nextSha === undefined
? undefined
: new KeyCommandQuickPickItem(Commands.ShowQuickCommitFileDetails, [
commit.nextUri,
nextCommandArgs
]);
}
else {
previousCommand = async () => {
let log = fileLog;
let c = log && log.commits.get(commit.sha);
// If we can't find the commit or the previous commit isn't available (since it isn't trustworthy)
if (c === undefined || c.previousSha === undefined) {
log = await Container.git.getLogForFile(commit.repoPath, uri.fsPath, {
maxCount: Container.config.advanced.maxListItems,
ref: commit.sha,
renames: true
});
if (log === undefined) return KeyNoopCommand;
c = log && log.commits.get(commit.sha);
// Since we exclude merge commits in file log, just grab the first returned commit
if (c === undefined && commit.isMerge) {
c = Iterables.first(log.commits.values());
}
if (c) {
// Copy over next info, since it is trustworthy at this point
c.nextSha = commit.nextSha;
c.nextFileName = commit.nextFileName;
}
}
if (c === undefined || c.previousSha === undefined) return KeyNoopCommand;
const previousCommandArgs: ShowQuickCommitFileDetailsCommandArgs = {
fileLog: log,
sha: c.previousSha,
goBackCommand: goBackCommand
};
return new KeyCommandQuickPickItem(Commands.ShowQuickCommitFileDetails, [
c.previousUri,
previousCommandArgs
]);
};
nextCommand = async () => {
let log = fileLog;
let c = log && log.commits.get(commit.sha);
// If we can't find the commit or the next commit isn't available (since it isn't trustworthy)
if (c === undefined || c.nextSha === undefined) {
log = undefined;
c = undefined;
// Try to find the next commit
const next = await Container.git.findNextCommit(commit.repoPath, uri.fsPath, commit.sha);
if (next !== undefined && next.sha !== commit.sha) {
c = commit;
c.nextSha = next.sha;
c.nextFileName = next.originalFileName || next.fileName;
}
}
if (c === undefined || c.nextSha === undefined) return KeyNoopCommand;
const nextCommandArgs: ShowQuickCommitFileDetailsCommandArgs = {
fileLog: log,
sha: c.nextSha,
goBackCommand: goBackCommand
};
return new KeyCommandQuickPickItem(Commands.ShowQuickCommitFileDetails, [
c.nextUri,
nextCommandArgs
]);
};
}
return new KeyCommandQuickPickItem(Commands.ShowQuickCommitFileDetails, [nextUri, nextCommandArgs]);
};
}
const scope = await Container.keyboard.beginScope({

+ 0
- 2
src/quickpicks/commitQuickPick.ts View File

@ -114,8 +114,6 @@ export class CommitQuickPick {
currentCommand?: CommandQuickPickItem,
repoLog?: GitLog
): Promise<CommitWithFileStatusQuickPickItem | CommandQuickPickItem | undefined> {
await commit.resolvePreviousFileSha();
const items: (CommitWithFileStatusQuickPickItem | CommandQuickPickItem)[] = commit.files.map(
fs => new CommitWithFileStatusQuickPickItem(commit, fs)
);

+ 4
- 7
src/quickpicks/fileHistoryQuickPick.ts View File

@ -62,11 +62,8 @@ export class FileHistoryQuickPick {
items.splice(0, 0, options.showAllCommand);
}
else if (!options.pickerOnly) {
const [workingFileName] = await Container.git.findWorkingFileName(
paths.relative(log.repoPath, uri.fsPath),
log.repoPath
);
if (workingFileName) {
const workingUri = await Container.git.getWorkingUri(log.repoPath, uri);
if (workingUri) {
const goBackCommandArgs: ShowQuickFileHistoryCommandArgs = {
log: log,
maxCount: log.maxCount,
@ -97,11 +94,11 @@ export class FileHistoryQuickPick {
{
label: '$(history) Show File History',
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} of ${paths.basename(
workingFileName
workingUri.fsPath
)}`
},
Commands.ShowQuickFileHistory,
[GitUri.resolveToUri(workingFileName, log.repoPath), commandArgs]
[workingUri, commandArgs]
)
);
}

+ 3
- 8
src/views/nodes/fileHistoryTrackerNode.ts View File

@ -127,14 +127,9 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
let uri;
if (gitUri.sha !== undefined) {
// If we have a sha, normalize the history to the working file (so we get a full history all the time)
const [fileName, repoPath] = await Container.git.findWorkingFileName(
gitUri.fsPath,
gitUri.repoPath,
gitUri.sha
);
if (fileName !== undefined) {
uri = GitUri.resolveToUri(fileName, repoPath);
const workingUri = await Container.git.getWorkingUri(gitUri.repoPath!, gitUri);
if (workingUri !== undefined) {
uri = workingUri;
}
}

+ 1
- 22
src/vsls/guest.ts View File

@ -6,13 +6,7 @@ import { GitCommandOptions, Repository, RepositoryChange } from '../git/git';
import { Logger } from '../logger';
import { debug, log } from '../system';
import { VslsHostService } from './host';
import {
GitCommandRequestType,
RepositoriesInFolderRequestType,
RepositoryProxy,
RequestType,
WorkspaceFileExistsRequestType
} from './protocol';
import { GitCommandRequestType, RepositoriesInFolderRequestType, RepositoryProxy, RequestType } from './protocol';
export class VslsGuestService implements Disposable {
@log()
@ -79,21 +73,6 @@ export class VslsGuestService implements Disposable {
);
}
@log()
async fileExists(
repoPath: string,
fileName: string,
options: { ensureCase: boolean } = { ensureCase: false }
): Promise<boolean> {
const response = await this.sendRequest(WorkspaceFileExistsRequestType, {
fileName: fileName,
repoPath: repoPath,
options: options
});
return response.exists;
}
@debug()
private sendRequest<TRequest, TResponse>(
requestType: RequestType<TRequest, TResponse>,

+ 1
- 23
src/vsls/host.ts View File

@ -13,10 +13,7 @@ import {
RepositoriesInFolderRequest,
RepositoriesInFolderRequestType,
RepositoriesInFolderResponse,
RequestType,
WorkspaceFileExistsRequest,
WorkspaceFileExistsRequestType,
WorkspaceFileExistsResponse
RequestType
} from './protocol';
import { vslsUriRootRegex } from './vsls';
@ -71,7 +68,6 @@ export class VslsHostService implements Disposable {
this.onRequest(GitCommandRequestType, this.onGitCommandRequest.bind(this));
this.onRequest(RepositoriesInFolderRequestType, this.onRepositoriesInFolderRequest.bind(this));
this.onRequest(WorkspaceFileExistsRequestType, this.onWorkspaceFileExistsRequest.bind(this));
void this.onWorkspaceFoldersChanged();
}
@ -229,24 +225,6 @@ export class VslsHostService implements Disposable {
};
}
@log()
private async onWorkspaceFileExistsRequest(
request: WorkspaceFileExistsRequest,
cancellation: CancellationToken
): Promise<WorkspaceFileExistsResponse> {
let { repoPath } = request;
if (this._sharedPathsRegex !== undefined && this._sharedPathsRegex.test(repoPath)) {
repoPath = Strings.normalizePath(repoPath).replace(this._sharedPathsRegex, (match, shared) => {
const local = this._sharedToLocalPaths!.get(shared);
return local != null ? local : shared;
});
}
// TODO: Lock this to be only in the contained workspaces
return { exists: await Container.git.fileExists(repoPath, request.fileName, request.options) };
}
@debug({
exit: result => `returned ${result.toString(true)}`
})

+ 0
- 14
src/vsls/protocol.ts View File

@ -36,17 +36,3 @@ export const RepositoriesInFolderRequestType = new RequestType<
RepositoriesInFolderRequest,
RepositoriesInFolderResponse
>('repositories/inFolder');
export interface WorkspaceFileExistsRequest {
fileName: string;
repoPath: string;
options: { ensureCase: boolean };
}
export interface WorkspaceFileExistsResponse {
exists: boolean;
}
export const WorkspaceFileExistsRequestType = new RequestType<WorkspaceFileExistsRequest, WorkspaceFileExistsResponse>(
'workspace/fileExists'
);

Loading…
Cancel
Save