mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-17 09:45:36 -05:00
Adds shortenSha method
This commit is contained in:
@@ -99,7 +99,7 @@ export class Git {
|
||||
static async getVersionedFile(repoPath: string | undefined, fileName: string, branchOrSha: string) {
|
||||
const data = await Git.show(repoPath, fileName, branchOrSha, 'binary');
|
||||
|
||||
const suffix = Git.isSha(branchOrSha) ? branchOrSha.substring(0, 8) : branchOrSha;
|
||||
const suffix = Git.isSha(branchOrSha) ? Git.shortenSha(branchOrSha) : branchOrSha;
|
||||
const ext = path.extname(fileName);
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
tmp.file({ prefix: `${path.basename(fileName, ext)}-${suffix}__`, postfix: ext },
|
||||
@@ -134,6 +134,10 @@ export class Git {
|
||||
return fileName && fileName.replace(/\\/g, '/');
|
||||
}
|
||||
|
||||
static shortenSha(sha: string) {
|
||||
return sha.substring(0, 8);
|
||||
}
|
||||
|
||||
static splitPath(fileName: string, repoPath: string | undefined, extract: boolean = true): [string, string] {
|
||||
if (repoPath) {
|
||||
fileName = this.normalizePath(fileName);
|
||||
|
||||
@@ -56,7 +56,7 @@ export class GitUri extends Uri {
|
||||
}
|
||||
|
||||
get shortSha() {
|
||||
return this.sha && this.sha.substring(0, 8);
|
||||
return this.sha && GitService.shortenSha(this.sha);
|
||||
}
|
||||
|
||||
fileUri() {
|
||||
|
||||
@@ -51,7 +51,7 @@ export class GitCommit {
|
||||
}
|
||||
|
||||
get shortSha() {
|
||||
return this.sha.substring(0, 8);
|
||||
return Git.shortenSha(this.sha);
|
||||
}
|
||||
|
||||
get isUncommitted(): boolean {
|
||||
@@ -62,7 +62,7 @@ export class GitCommit {
|
||||
}
|
||||
|
||||
get previousShortSha() {
|
||||
return this.previousSha && this.previousSha.substring(0, 8);
|
||||
return this.previousSha && Git.shortenSha(this.previousSha);
|
||||
}
|
||||
|
||||
get previousUri(): Uri {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
import { Uri } from 'vscode';
|
||||
import { GitCommit, GitCommitType } from './commit';
|
||||
import { Git } from '../git';
|
||||
import { GitStatusFileStatus, IGitStatusFile } from './status';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -49,7 +50,7 @@ export class GitLogCommit extends GitCommit {
|
||||
}
|
||||
|
||||
get nextShortSha() {
|
||||
return this.nextSha && this.nextSha.substring(0, 8);
|
||||
return this.nextSha && Git.shortenSha(this.nextSha);
|
||||
}
|
||||
|
||||
get nextUri(): Uri {
|
||||
|
||||
Reference in New Issue
Block a user