mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-19 09:45:36 -05:00
Adds fromFileStatus to GitUri
This commit is contained in:
@@ -5,7 +5,6 @@ import { ActiveEditorCommand, Commands } from './common';
|
||||
import { TextEditorComparer, UriComparer } from '../comparers';
|
||||
import { GitService } from '../gitService';
|
||||
import { Logger } from '../logger';
|
||||
import * as path from 'path';
|
||||
|
||||
export class CloseUnchangedFilesCommand extends ActiveEditorCommand {
|
||||
|
||||
@@ -26,7 +25,7 @@ export class CloseUnchangedFilesCommand extends ActiveEditorCommand {
|
||||
const status = await this.git.getStatusForRepo(repoPath);
|
||||
if (!status) return window.showWarningMessage(`Unable to close unchanged files`);
|
||||
|
||||
uris = status.files.map(_ => Uri.file(path.resolve(repoPath, _.fileName)));
|
||||
uris = status.files.map(_ => _.Uri);
|
||||
}
|
||||
|
||||
const editorTracker = new ActiveEditorTracker();
|
||||
|
||||
@@ -3,7 +3,6 @@ import { TextEditor, Uri, window } from 'vscode';
|
||||
import { ActiveEditorCommand, Commands, openEditor } from './common';
|
||||
import { GitService } from '../gitService';
|
||||
import { Logger } from '../logger';
|
||||
import * as path from 'path';
|
||||
|
||||
export class OpenChangedFilesCommand extends ActiveEditorCommand {
|
||||
|
||||
@@ -24,7 +23,7 @@ export class OpenChangedFilesCommand extends ActiveEditorCommand {
|
||||
const status = await this.git.getStatusForRepo(repoPath);
|
||||
if (!status) return window.showWarningMessage(`Unable to open changed files`);
|
||||
|
||||
uris = status.files.filter(_ => _.status !== 'D').map(_ => Uri.file(path.resolve(repoPath, _.fileName)));
|
||||
uris = status.files.filter(_ => _.status !== 'D').map(_ => _.Uri);
|
||||
}
|
||||
|
||||
for (const uri of uris) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
import { Uri } from 'vscode';
|
||||
import { DocumentSchemes } from '../constants';
|
||||
import { Git, GitService } from '../gitService';
|
||||
import { Git, GitCommit, GitService, IGitStatusFile } from '../gitService';
|
||||
import * as path from 'path';
|
||||
|
||||
export class GitUri extends Uri {
|
||||
@@ -12,6 +12,7 @@ export class GitUri extends Uri {
|
||||
|
||||
constructor(uri?: Uri, commit?: IGitCommitInfo);
|
||||
constructor(uri?: Uri, repoPath?: string);
|
||||
constructor(uri?: Uri, commitOrRepoPath?: IGitCommitInfo | string);
|
||||
constructor(uri?: Uri, commitOrRepoPath?: IGitCommitInfo | string) {
|
||||
super();
|
||||
if (!uri) return;
|
||||
@@ -88,6 +89,14 @@ export class GitUri extends Uri {
|
||||
|
||||
return new GitUri(uri, git && git.repoPath);
|
||||
}
|
||||
|
||||
static fromFileStatus(status: IGitStatusFile, repoPath: string, original?: boolean): GitUri;
|
||||
static fromFileStatus(status: IGitStatusFile, commit: GitCommit, original?: boolean): GitUri;
|
||||
static fromFileStatus(status: IGitStatusFile, repoPathOrCommit: string | GitCommit, original: boolean = false): GitUri {
|
||||
const repoPath = repoPathOrCommit instanceof GitCommit ? repoPathOrCommit.repoPath : repoPathOrCommit;
|
||||
const uri = Uri.file(path.resolve(repoPath, original ? status.originalFileName || status.fileName : status.fileName));
|
||||
return new GitUri(uri, repoPathOrCommit);
|
||||
}
|
||||
}
|
||||
|
||||
export interface IGitCommitInfo {
|
||||
|
||||
@@ -34,7 +34,7 @@ export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickI
|
||||
});
|
||||
|
||||
this.fileName = status.fileName;
|
||||
this.gitUri = new GitUri(Uri.file(path.resolve(commit.repoPath, status.fileName)));
|
||||
this.gitUri = GitUri.fromFileStatus(status, commit.repoPath);
|
||||
this.sha = commit.sha;
|
||||
this.shortSha = commit.shortSha;
|
||||
this.status = status.status;
|
||||
@@ -58,7 +58,7 @@ export class OpenCommitWorkingTreeFilesCommandQuickPickItem extends OpenFilesCom
|
||||
|
||||
constructor(commit: GitLogCommit, versioned: boolean = false, item?: QuickPickItem) {
|
||||
const repoPath = commit.repoPath;
|
||||
const uris = commit.fileStatuses.map(_ => Uri.file(path.resolve(repoPath, _.fileName)));
|
||||
const uris = commit.fileStatuses.map(_ => GitUri.fromFileStatus(_, repoPath));
|
||||
super(uris, item || {
|
||||
label: `$(file-symlink-file) Open Changed Working Files`,
|
||||
description: undefined
|
||||
|
||||
Reference in New Issue
Block a user