mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-11 02:32:36 -05:00
Fixes issues with ^ in a sha
Dynamically pads uri index based on need
This commit is contained in:
14
src/git.ts
14
src/git.ts
@@ -11,17 +11,18 @@ export declare interface IGitBlameLine {
|
||||
author: string;
|
||||
date: Date;
|
||||
line: number;
|
||||
code: string;
|
||||
//code: string;
|
||||
}
|
||||
|
||||
export function gitRepoPath(cwd) {
|
||||
return gitCommand(cwd, 'rev-parse', '--show-toplevel').then(data => data.replace(/\r?\n|\r/g, ''));
|
||||
}
|
||||
|
||||
const blameMatcher = /^([0-9a-fA-F]{8})\s([\S]*)\s+([0-9\S]+)\s\((.*)\s([0-9]{4}-[0-9]{2}-[0-9]{2}\s[0-9]{2}:[0-9]{2}:[0-9]{2}\s[-|+][0-9]{4})\s+([0-9]+)\)(.*)$/gm;
|
||||
const blameMatcher = /^([\^0-9a-fA-F]{8})\s([\S]*)\s+([0-9\S]+)\s\((.*)\s([0-9]{4}-[0-9]{2}-[0-9]{2}\s[0-9]{2}:[0-9]{2}:[0-9]{2}\s[-|+][0-9]{4})\s+([0-9]+)\)(.*)$/gm;
|
||||
|
||||
export function gitBlame(fileName: string) {
|
||||
return gitCommand(dirname(fileName), 'blame', '-fnw', '--', fileName).then(data => {
|
||||
console.log('git', 'blame', '-fnw', '--root', '--', fileName);
|
||||
return gitCommand(dirname(fileName), 'blame', '-fnw', '--root', '--', fileName).then(data => {
|
||||
let lines: Array<IGitBlameLine> = [];
|
||||
let m: Array<string>;
|
||||
while ((m = blameMatcher.exec(data)) != null) {
|
||||
@@ -31,8 +32,8 @@ export function gitBlame(fileName: string) {
|
||||
originalLine: parseInt(m[3], 10) - 1,
|
||||
author: m[4].trim(),
|
||||
date: new Date(m[5]),
|
||||
line: parseInt(m[6], 10) - 1,
|
||||
code: m[7]
|
||||
line: parseInt(m[6], 10) - 1
|
||||
//code: m[7]
|
||||
});
|
||||
}
|
||||
return lines;
|
||||
@@ -41,7 +42,7 @@ export function gitBlame(fileName: string) {
|
||||
|
||||
export function gitGetVersionFile(repoPath: string, sha: string, source: string): Promise<string> {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
gitCommand(repoPath, 'show', `${sha}:${source.replace(/\\/g, '/')}`).then(data => {
|
||||
gitCommand(repoPath, 'show', `${sha.replace('^', '')}:${source.replace(/\\/g, '/')}`).then(data => {
|
||||
let ext = extname(source);
|
||||
tmp.file({ prefix: `${basename(source, ext)}-${sha}_`, postfix: ext }, (err, destination, fd, cleanupCallback) => {
|
||||
if (err) {
|
||||
@@ -65,6 +66,7 @@ export function gitGetVersionFile(repoPath: string, sha: string, source: string)
|
||||
}
|
||||
|
||||
export function gitGetVersionText(repoPath: string, sha: string, source: string) {
|
||||
console.log('git', 'show', `${sha}:${source.replace(/\\/g, '/')}`);
|
||||
return gitCommand(repoPath, 'show', `${sha}:${source.replace(/\\/g, '/')}`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user