Преглед изворни кода

Fixes `gitlens-git` file paths and blameability

main
Eric Amodio пре 7 година
родитељ
комит
1cecab43f5
1 измењених фајлова са 17 додато и 12 уклоњено
  1. +17
    -12
      src/git/gitUri.ts

+ 17
- 12
src/git/gitUri.ts Прегледај датотеку

@ -5,7 +5,12 @@ import { DocumentSchemes, GlyphChars } from '../constants';
import { GitService, IGitStatusFile } from '../gitService';
import * as path from 'path';
export class GitUri extends Uri {
interface UriEx {
new(): Uri;
new(scheme: string, authority: string, path: string, query: string, fragment: string): Uri;
}
export class GitUri extends (Uri as UriEx) {
offset: number;
repoPath?: string | undefined;
@ -15,20 +20,14 @@ export class GitUri extends Uri {
constructor(uri?: Uri, repoPath?: string);
constructor(uri?: Uri, commitOrRepoPath?: IGitCommitInfo | string);
constructor(uri?: Uri, commitOrRepoPath?: IGitCommitInfo | string) {
super();
if (!uri) return;
const base = this as any;
for (const key in uri) {
if (uri.hasOwnProperty(key)) {
base[key] = (uri as any)[key];
}
if (uri === undefined) {
super();
return;
}
this.offset = 0;
if (uri.scheme === DocumentSchemes.GitLensGit) {
const data = GitService.fromGitContentUri(uri);
base._fsPath = path.resolve(data.repoPath, data.originalFileName || data.fileName);
super(uri.scheme, uri.authority, path.resolve(data.repoPath, data.originalFileName || data.fileName), uri.query, uri.fragment);
this.offset = (data.decoration && data.decoration.split('\n').length) || 0;
if (!GitService.isUncommitted(data.sha)) {
@ -38,12 +37,16 @@ export class GitUri extends Uri {
}
else if (commitOrRepoPath) {
if (typeof commitOrRepoPath === 'string') {
super(uri.scheme, uri.authority, uri.path, uri.query, uri.fragment);
this.offset = 0;
this.repoPath = commitOrRepoPath;
}
else {
const commit = commitOrRepoPath;
base._fsPath = path.resolve(commit.repoPath, commit.originalFileName || commit.fileName || '');
super(uri.scheme, uri.authority, path.resolve(commit.repoPath, commit.originalFileName || commit.fileName || ''), uri.query, uri.fragment);
this.offset = 0;
if (commit.repoPath !== undefined) {
this.repoPath = commit.repoPath;
}
@ -91,6 +94,8 @@ export class GitUri extends Uri {
if (!git.isTrackable(uri)) return new GitUri(uri, git.repoPath);
if (uri.scheme === DocumentSchemes.GitLensGit) return new GitUri(uri);
// If this is a git uri, assume it is showing the most recent commit
if (uri.scheme === DocumentSchemes.Git) {
const commit = await git.getLogCommit(undefined, uri.fsPath);

Loading…
Откажи
Сачувај