mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-16 09:35:40 -05:00
Switches everything to use full shas
This commit is contained in:
@@ -5,6 +5,7 @@ import * as path from 'path';
|
||||
|
||||
interface IBlameEntry {
|
||||
sha: string;
|
||||
|
||||
line: number;
|
||||
originalLine: number;
|
||||
lineCount: number;
|
||||
@@ -53,7 +54,7 @@ export class GitBlameParserEnricher implements IGitEnricher<IGitBlame> {
|
||||
|
||||
if (!entry) {
|
||||
entry = {
|
||||
sha: lineParts[0].substring(0, 8),
|
||||
sha: lineParts[0],
|
||||
originalLine: parseInt(lineParts[1], 10) - 1,
|
||||
line: parseInt(lineParts[2], 10) - 1,
|
||||
lineCount: parseInt(lineParts[3], 10)
|
||||
@@ -102,7 +103,7 @@ export class GitBlameParserEnricher implements IGitEnricher<IGitBlame> {
|
||||
break;
|
||||
|
||||
case 'previous':
|
||||
entry.previousSha = lineParts[1].substring(0, 8);
|
||||
entry.previousSha = lineParts[1];
|
||||
entry.previousFileName = lineParts.slice(2).join(' ');
|
||||
break;
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ interface ILogEntry {
|
||||
summary?: string;
|
||||
}
|
||||
|
||||
const shaRegex = /^[a-f0-9]{40}$/;
|
||||
|
||||
export class GitLogParserEnricher implements IGitEnricher<IGitLog> {
|
||||
|
||||
private _parseEntries(data: string, isRepoPath: boolean): ILogEntry[] {
|
||||
@@ -40,9 +42,9 @@ export class GitLogParserEnricher implements IGitEnricher<IGitLog> {
|
||||
}
|
||||
|
||||
if (!entry) {
|
||||
if (!/^[a-f0-9]{40}$/.test(lineParts[0])) continue;
|
||||
if (!shaRegex.test(lineParts[0])) continue;
|
||||
entry = {
|
||||
sha: lineParts[0].substring(0, 8)
|
||||
sha: lineParts[0]
|
||||
};
|
||||
|
||||
continue;
|
||||
|
||||
@@ -115,9 +115,10 @@ export default class Git {
|
||||
static async getVersionedFile(fileName: string, repoPath: string, sha: string) {
|
||||
const data = await Git.getVersionedFileText(fileName, repoPath, sha);
|
||||
|
||||
const shortSha = sha.substring(0, 8);
|
||||
const ext = path.extname(fileName);
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
tmp.file({ prefix: `${path.basename(fileName, ext)}-${sha}__`, postfix: ext },
|
||||
tmp.file({ prefix: `${path.basename(fileName, ext)}-${shortSha}__`, postfix: ext },
|
||||
(err, destination, fd, cleanupCallback) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
|
||||
@@ -80,6 +80,10 @@ export class GitCommit implements IGitCommit {
|
||||
this.previousFileName = previousFileName;
|
||||
}
|
||||
|
||||
get shortSha() {
|
||||
return this.sha.substring(0, 8);
|
||||
}
|
||||
|
||||
get isUncommitted(): boolean {
|
||||
if (this._isUncommitted === undefined) {
|
||||
this._isUncommitted = Git.isUncommitted(this.sha);
|
||||
@@ -87,6 +91,10 @@ export class GitCommit implements IGitCommit {
|
||||
return this._isUncommitted;
|
||||
}
|
||||
|
||||
get previousShortSha() {
|
||||
return this.previousSha && this.previousSha.substring(0, 8);
|
||||
}
|
||||
|
||||
get previousUri(): Uri {
|
||||
return this.previousFileName ? Uri.file(path.join(this.repoPath, this.previousFileName)) : this.uri;
|
||||
}
|
||||
@@ -138,6 +146,10 @@ export class GitLogCommit extends GitCommit {
|
||||
}
|
||||
}
|
||||
|
||||
get nextShortSha() {
|
||||
return this.nextSha && this.nextSha.substring(0, 8);
|
||||
}
|
||||
|
||||
get nextUri(): Uri {
|
||||
return this.nextFileName ? Uri.file(path.join(this.repoPath, this.nextFileName)) : this.uri;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,10 @@ export class GitUri extends Uri {
|
||||
}
|
||||
}
|
||||
|
||||
get shortSha() {
|
||||
return this.sha && this.sha.substring(0, 8);
|
||||
}
|
||||
|
||||
fileUri() {
|
||||
return Uri.file(this.sha ? this.path : this.fsPath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user