mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-18 09:45:36 -05:00
Adds fromFileStatus to GitUri
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user