Browse Source

Changes status file call to use Uris

main
Eric Amodio 2 years ago
parent
commit
22b11e61a9
9 changed files with 28 additions and 28 deletions
  1. +1
    -1
      src/annotations/gutterChangesAnnotationProvider.ts
  2. +1
    -1
      src/commands/diffLineWithWorking.ts
  3. +1
    -1
      src/commands/diffWithWorking.ts
  4. +1
    -1
      src/commands/externalDiff.ts
  5. +19
    -19
      src/env/node/git/localGitProvider.ts
  6. +1
    -1
      src/git/gitProvider.ts
  7. +2
    -2
      src/git/gitProviderService.ts
  8. +1
    -1
      src/premium/github/githubGitProvider.ts
  9. +1
    -1
      src/views/nodes/lineHistoryNode.ts

+ 1
- 1
src/annotations/gutterChangesAnnotationProvider.ts View File

@ -101,7 +101,7 @@ export class GutterChangesAnnotationProvider extends AnnotationProviderBase
} else { } else {
const status = await this.container.git.getStatusForFile( const status = await this.container.git.getStatusForFile(
this.trackedDocument.uri.repoPath!, this.trackedDocument.uri.repoPath!,
this.trackedDocument.uri.fsPath,
this.trackedDocument.uri,
); );
const commits = status?.getPseudoCommits( const commits = status?.getPseudoCommits(
this.container, this.container,

+ 1
- 1
src/commands/diffLineWithWorking.ts View File

@ -52,7 +52,7 @@ export class DiffLineWithWorkingCommand extends ActiveEditorCommand {
// If the line is uncommitted, use previous commit (or index if the file is staged) // If the line is uncommitted, use previous commit (or index if the file is staged)
if (args.commit.isUncommitted) { if (args.commit.isUncommitted) {
const status = await this.container.git.getStatusForFile(gitUri.repoPath!, gitUri.fsPath);
const status = await this.container.git.getStatusForFile(gitUri.repoPath!, gitUri);
if (status?.indexStatus != null) { if (status?.indexStatus != null) {
lhsSha = GitRevision.uncommittedStaged; lhsSha = GitRevision.uncommittedStaged;
lhsUri = this.container.git.getAbsoluteUri( lhsUri = this.container.git.getAbsoluteUri(

+ 1
- 1
src/commands/diffWithWorking.ts View File

@ -65,7 +65,7 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
// If we are a fake "staged" sha, check the status // If we are a fake "staged" sha, check the status
if (gitUri.isUncommittedStaged) { if (gitUri.isUncommittedStaged) {
const status = await this.container.git.getStatusForFile(gitUri.repoPath!, gitUri.fsPath);
const status = await this.container.git.getStatusForFile(gitUri.repoPath!, gitUri);
if (status?.indexStatus != null) { if (status?.indexStatus != null) {
void (await executeCommand<DiffWithCommandArgs>(Commands.DiffWith, { void (await executeCommand<DiffWithCommandArgs>(Commands.DiffWith, {
repoPath: gitUri.repoPath, repoPath: gitUri.repoPath,

+ 1
- 1
src/commands/externalDiff.ts View File

@ -133,7 +133,7 @@ export class ExternalDiffCommand extends Command {
if (!repoPath) return; if (!repoPath) return;
const uri = editor.document.uri; const uri = editor.document.uri;
const status = await this.container.git.getStatusForFile(repoPath, uri.fsPath);
const status = await this.container.git.getStatusForFile(repoPath, uri);
if (status == null) { if (status == null) {
void window.showInformationMessage("The current file doesn't have any changes"); void window.showInformationMessage("The current file doesn't have any changes");

+ 19
- 19
src/env/node/git/localGitProvider.ts View File

@ -2661,38 +2661,38 @@ export class LocalGitProvider implements GitProvider, Disposable {
// If we have no ref (or staged ref) there is no next commit // If we have no ref (or staged ref) there is no next commit
if (ref == null || ref.length === 0) return undefined; if (ref == null || ref.length === 0) return undefined;
const fileName = GitUri.relativeTo(uri, repoPath);
const path = this.getRelativePath(uri, repoPath);
if (GitRevision.isUncommittedStaged(ref)) { if (GitRevision.isUncommittedStaged(ref)) {
return { return {
current: GitUri.fromFile(fileName, repoPath, ref),
next: GitUri.fromFile(fileName, repoPath, undefined),
current: GitUri.fromFile(path, repoPath, ref),
next: GitUri.fromFile(path, repoPath, undefined),
}; };
} }
const next = await this.getNextUri(repoPath, uri, ref, skip); const next = await this.getNextUri(repoPath, uri, ref, skip);
if (next == null) { if (next == null) {
const status = await this.getStatusForFile(repoPath, fileName);
const status = await this.getStatusForFile(repoPath, uri);
if (status != null) { if (status != null) {
// If the file is staged, diff with the staged version // If the file is staged, diff with the staged version
if (status.indexStatus != null) { if (status.indexStatus != null) {
return { return {
current: GitUri.fromFile(fileName, repoPath, ref),
next: GitUri.fromFile(fileName, repoPath, GitRevision.uncommittedStaged),
current: GitUri.fromFile(path, repoPath, ref),
next: GitUri.fromFile(path, repoPath, GitRevision.uncommittedStaged),
}; };
} }
} }
return { return {
current: GitUri.fromFile(fileName, repoPath, ref),
next: GitUri.fromFile(fileName, repoPath, undefined),
current: GitUri.fromFile(path, repoPath, ref),
next: GitUri.fromFile(path, repoPath, undefined),
}; };
} }
return { return {
current: current:
skip === 0 skip === 0
? GitUri.fromFile(fileName, repoPath, ref)
? GitUri.fromFile(path, repoPath, ref)
: (await this.getNextUri(repoPath, uri, ref, skip - 1))!, : (await this.getNextUri(repoPath, uri, ref, skip - 1))!,
next: next, next: next,
}; };
@ -2769,7 +2769,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
// If we are at the working tree (i.e. no ref), we need to dig deeper to figure out where to go // If we are at the working tree (i.e. no ref), we need to dig deeper to figure out where to go
if (!ref) { if (!ref) {
// First, check the file status to see if there is anything staged // First, check the file status to see if there is anything staged
const status = await this.getStatusForFile(repoPath, path);
const status = await this.getStatusForFile(repoPath, uri);
if (status != null) { if (status != null) {
// If the file is staged with working changes, diff working with staged (index) // If the file is staged with working changes, diff working with staged (index)
// If the file is staged without working changes, diff staged with HEAD // If the file is staged without working changes, diff staged with HEAD
@ -2861,7 +2861,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
// If the document is dirty (unsaved), use the status to determine where to go // If the document is dirty (unsaved), use the status to determine where to go
if (document.isDirty) { if (document.isDirty) {
// Check the file status to see if there is anything staged // Check the file status to see if there is anything staged
const status = await this.getStatusForFile(repoPath, path);
const status = await this.getStatusForFile(repoPath, uri);
if (status != null) { if (status != null) {
// If the file is staged, diff working with staged (index) // If the file is staged, diff working with staged (index)
// If the file is not staged, diff working with HEAD // If the file is not staged, diff working with HEAD
@ -2985,7 +2985,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
// If the line count is invalid just fallback to the most recent commit // If the line count is invalid just fallback to the most recent commit
if ((ref == null || GitRevision.isUncommittedStaged(ref)) && GitErrors.invalidLineCount.test(msg)) { if ((ref == null || GitRevision.isUncommittedStaged(ref)) && GitErrors.invalidLineCount.test(msg)) {
if (ref == null) { if (ref == null) {
const status = await this.getStatusForFile(repoPath, path);
const status = await this.getStatusForFile(repoPath, uri);
if (status?.indexStatus != null) { if (status?.indexStatus != null) {
return GitUri.fromFile(path, repoPath, GitRevision.uncommittedStaged); return GitUri.fromFile(path, repoPath, GitRevision.uncommittedStaged);
} }
@ -3123,15 +3123,15 @@ export class LocalGitProvider implements GitProvider, Disposable {
} }
@log() @log()
async getStatusForFile(repoPath: string, path: string): Promise<GitStatusFile | undefined> {
async getStatusForFile(repoPath: string, uri: Uri): Promise<GitStatusFile | undefined> {
const porcelainVersion = (await this.git.isAtLeastVersion('2.11')) ? 2 : 1; const porcelainVersion = (await this.git.isAtLeastVersion('2.11')) ? 2 : 1;
[path, repoPath] = splitPath(path, repoPath);
const [relativePath, root] = splitPath(getBestPath(uri), repoPath);
const data = await this.git.status__file(repoPath, path, porcelainVersion, {
const data = await this.git.status__file(root, relativePath, porcelainVersion, {
similarityThreshold: this.container.config.advanced.similarityThreshold, similarityThreshold: this.container.config.advanced.similarityThreshold,
}); });
const status = GitStatusParser.parse(data, repoPath, porcelainVersion);
const status = GitStatusParser.parse(data, root, porcelainVersion);
if (status == null || !status.files.length) return undefined; if (status == null || !status.files.length) return undefined;
return status.files[0]; return status.files[0];
@ -3141,12 +3141,12 @@ export class LocalGitProvider implements GitProvider, Disposable {
async getStatusForFiles(repoPath: string, pathOrGlob: string): Promise<GitStatusFile[] | undefined> { async getStatusForFiles(repoPath: string, pathOrGlob: string): Promise<GitStatusFile[] | undefined> {
const porcelainVersion = (await this.git.isAtLeastVersion('2.11')) ? 2 : 1; const porcelainVersion = (await this.git.isAtLeastVersion('2.11')) ? 2 : 1;
[pathOrGlob, repoPath] = splitPath(pathOrGlob, repoPath);
const [relativePath, root] = splitPath(pathOrGlob, repoPath);
const data = await this.git.status__file(repoPath, pathOrGlob, porcelainVersion, {
const data = await this.git.status__file(root, relativePath, porcelainVersion, {
similarityThreshold: this.container.config.advanced.similarityThreshold, similarityThreshold: this.container.config.advanced.similarityThreshold,
}); });
const status = GitStatusParser.parse(data, repoPath, porcelainVersion);
const status = GitStatusParser.parse(data, root, porcelainVersion);
if (status == null || !status.files.length) return []; if (status == null || !status.files.length) return [];
return status.files; return status.files;

+ 1
- 1
src/git/gitProvider.ts View File

@ -337,7 +337,7 @@ export interface GitProvider extends Disposable {
): Promise<GitRemote<RemoteProvider | RichRemoteProvider | undefined>[]>; ): Promise<GitRemote<RemoteProvider | RichRemoteProvider | undefined>[]>;
getRevisionContent(repoPath: string, path: string, ref: string): Promise<Uint8Array | undefined>; getRevisionContent(repoPath: string, path: string, ref: string): Promise<Uint8Array | undefined>;
getStash(repoPath: string | undefined): Promise<GitStash | undefined>; getStash(repoPath: string | undefined): Promise<GitStash | undefined>;
getStatusForFile(repoPath: string, path: string): Promise<GitStatusFile | undefined>;
getStatusForFile(repoPath: string, uri: Uri): Promise<GitStatusFile | undefined>;
getStatusForFiles(repoPath: string, pathOrGlob: string): Promise<GitStatusFile[] | undefined>; getStatusForFiles(repoPath: string, pathOrGlob: string): Promise<GitStatusFile[] | undefined>;
getStatusForRepo(repoPath: string | undefined): Promise<GitStatus | undefined>; getStatusForRepo(repoPath: string | undefined): Promise<GitStatus | undefined>;
getTags( getTags(

+ 2
- 2
src/git/gitProviderService.ts View File

@ -1707,9 +1707,9 @@ export class GitProviderService implements Disposable {
} }
@log() @log()
async getStatusForFile(repoPath: string | Uri, fileName: string): Promise<GitStatusFile | undefined> {
async getStatusForFile(repoPath: string | Uri, uri: Uri): Promise<GitStatusFile | undefined> {
const { provider, path } = this.getProvider(repoPath); const { provider, path } = this.getProvider(repoPath);
return provider.getStatusForFile(path, fileName);
return provider.getStatusForFile(path, uri);
} }
@log() @log()

+ 1
- 1
src/premium/github/githubGitProvider.ts View File

@ -1757,7 +1757,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
} }
@log() @log()
async getStatusForFile(_repoPath: string, _path: string): Promise<GitStatusFile | undefined> {
async getStatusForFile(_repoPath: string, _uri: Uri): Promise<GitStatusFile | undefined> {
return undefined; return undefined;
} }

+ 1
- 1
src/views/nodes/lineHistoryNode.ts View File

@ -102,7 +102,7 @@ export class LineHistoryNode
selection.active.character, selection.active.character,
); );
const status = await this.view.container.git.getStatusForFile(this.uri.repoPath!, this.uri.fsPath);
const status = await this.view.container.git.getStatusForFile(this.uri.repoPath!, this.uri);
if (status != null) { if (status != null) {
const file: GitFile = { const file: GitFile = {

Loading…
Cancel
Save