소스 검색

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 { GitService, IGitStatusFile } from '../gitService';
import * as path from 'path'; 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; offset: number;
repoPath?: string | undefined; repoPath?: string | undefined;
@ -15,20 +20,14 @@ export class GitUri extends Uri {
constructor(uri?: Uri, repoPath?: string); constructor(uri?: Uri, repoPath?: string);
constructor(uri?: Uri, commitOrRepoPath?: IGitCommitInfo | string); constructor(uri?: Uri, commitOrRepoPath?: IGitCommitInfo | 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) { if (uri.scheme === DocumentSchemes.GitLensGit) {
const data = GitService.fromGitContentUri(uri); 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; this.offset = (data.decoration && data.decoration.split('\n').length) || 0;
if (!GitService.isUncommitted(data.sha)) { if (!GitService.isUncommitted(data.sha)) {
@ -38,12 +37,16 @@ export class GitUri extends Uri {
} }
else if (commitOrRepoPath) { else if (commitOrRepoPath) {
if (typeof commitOrRepoPath === 'string') { if (typeof commitOrRepoPath === 'string') {
super(uri.scheme, uri.authority, uri.path, uri.query, uri.fragment);
this.offset = 0;
this.repoPath = commitOrRepoPath; this.repoPath = commitOrRepoPath;
} }
else { else {
const commit = commitOrRepoPath; 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) { if (commit.repoPath !== undefined) {
this.repoPath = commit.repoPath; this.repoPath = commit.repoPath;
} }
@ -91,6 +94,8 @@ export class GitUri extends Uri {
if (!git.isTrackable(uri)) return new GitUri(uri, git.repoPath); 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 this is a git uri, assume it is showing the most recent commit
if (uri.scheme === DocumentSchemes.Git) { if (uri.scheme === DocumentSchemes.Git) {
const commit = await git.getLogCommit(undefined, uri.fsPath); const commit = await git.getLogCommit(undefined, uri.fsPath);

불러오는 중...
취소
저장