mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-15 17:25:33 -05:00
Adds error messages for failed operations
Adds showHistory command support to CodeLens Fixes and improve the showHistory explorer Refactoring
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
import { GitBlameFormat, GitCommit, IGitAuthor, IGitBlame, IGitCommit, IGitCommitLine, IGitEnricher } from './../git';
|
||||
import { GitBlameFormat, GitCommit, IGitAuthor, IGitBlame, IGitCommitLine, IGitEnricher } from './../git';
|
||||
import * as moment from 'moment';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -123,7 +123,7 @@ export class GitBlameParserEnricher implements IGitEnricher<IGitBlame> {
|
||||
if (!entries) return null;
|
||||
|
||||
const authors: Map<string, IGitAuthor> = new Map();
|
||||
const commits: Map<string, IGitCommit> = new Map();
|
||||
const commits: Map<string, GitCommit> = new Map();
|
||||
const lines: Array<IGitCommitLine> = [];
|
||||
|
||||
let repoPath: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
import { GitCommit, IGitAuthor, IGitCommit, IGitEnricher, IGitLog } from './../git';
|
||||
import { GitCommit, IGitAuthor, IGitEnricher, IGitLog } from './../git';
|
||||
import * as moment from 'moment';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -35,6 +35,7 @@ export class GitLogParserEnricher implements IGitEnricher<IGitLog> {
|
||||
}
|
||||
|
||||
if (!entry) {
|
||||
if (!/^[a-f0-9]{40}$/.test(lineParts[0])) continue;
|
||||
entry = {
|
||||
sha: lineParts[0].substring(0, 8)
|
||||
};
|
||||
@@ -66,7 +67,13 @@ export class GitLogParserEnricher implements IGitEnricher<IGitLog> {
|
||||
case 'filename':
|
||||
position += 2;
|
||||
lineParts = lines[position].split(' ');
|
||||
entry.fileName = lineParts.join(' ');
|
||||
if (lineParts.length === 1) {
|
||||
entry.fileName = lineParts[0];
|
||||
}
|
||||
else {
|
||||
entry.fileName = lineParts[3].substring(2);
|
||||
position += 4;
|
||||
}
|
||||
|
||||
entries.push(entry);
|
||||
entry = null;
|
||||
@@ -85,10 +92,11 @@ export class GitLogParserEnricher implements IGitEnricher<IGitLog> {
|
||||
if (!entries) return null;
|
||||
|
||||
const authors: Map<string, IGitAuthor> = new Map();
|
||||
const commits: Map<string, IGitCommit> = new Map();
|
||||
const commits: Map<string, GitCommit> = new Map();
|
||||
|
||||
let repoPath: string;
|
||||
let relativeFileName: string;
|
||||
let recentCommit: GitCommit;
|
||||
|
||||
for (let i = 0, len = entries.length; i < len; i++) {
|
||||
const entry = entries[i];
|
||||
@@ -118,6 +126,12 @@ export class GitLogParserEnricher implements IGitEnricher<IGitLog> {
|
||||
|
||||
commits.set(entry.sha, commit);
|
||||
}
|
||||
|
||||
if (recentCommit) {
|
||||
recentCommit.previousSha = commit.sha;
|
||||
recentCommit.previousFileName = commit.originalFileName || commit.fileName;
|
||||
}
|
||||
recentCommit = commit;
|
||||
}
|
||||
|
||||
commits.forEach(c => authors.get(c.author).lineCount += c.lines.length);
|
||||
|
||||
@@ -77,7 +77,13 @@ export default class Git {
|
||||
static log(fileName: string, repoPath?: string) {
|
||||
const [file, root]: [string, string] = Git.splitPath(Git.normalizePath(fileName), repoPath);
|
||||
|
||||
return gitCommand(root, 'log', `--follow`, `--name-only`, `--no-merges`, `--format=%H -%nauthor %an%nauthor-date %ai%ncommitter %cn%ncommitter-date %ci%nsummary %s%nfilename -`, file);
|
||||
return gitCommand(root, 'log', `--follow`, `--name-only`, `--no-merges`, `--format=%H -%nauthor %an%nauthor-date %ai%ncommitter %cn%ncommitter-date %ci%nsummary %s%nfilename ?`, file);
|
||||
}
|
||||
|
||||
static logRange(fileName: string, start: number, end: number, repoPath?: string) {
|
||||
const [file, root]: [string, string] = Git.splitPath(Git.normalizePath(fileName), repoPath);
|
||||
|
||||
return gitCommand(root, 'log', `--name-only`, `--no-merges`, `--format=%H -%nauthor %an%nauthor-date %ai%ncommitter %cn%ncommitter-date %ci%nsummary %s%nfilename ?`, `-L ${start},${end}:${file}`);
|
||||
}
|
||||
|
||||
static getVersionedFile(fileName: string, repoPath: string, sha: string) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
import {Uri} from 'vscode';
|
||||
import { Uri } from 'vscode';
|
||||
import Git from './git';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -10,13 +10,13 @@ export interface IGitEnricher<T> {
|
||||
export interface IGitBlame {
|
||||
repoPath: string;
|
||||
authors: Map<string, IGitAuthor>;
|
||||
commits: Map<string, IGitCommit>;
|
||||
commits: Map<string, GitCommit>;
|
||||
lines: IGitCommitLine[];
|
||||
}
|
||||
|
||||
export interface IGitBlameLine {
|
||||
author: IGitAuthor;
|
||||
commit: IGitCommit;
|
||||
commit: GitCommit;
|
||||
line: IGitCommitLine;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export interface IGitBlameLines extends IGitBlame {
|
||||
|
||||
export interface IGitBlameCommitLines {
|
||||
author: IGitAuthor;
|
||||
commit: IGitCommit;
|
||||
commit: GitCommit;
|
||||
lines: IGitCommitLine[];
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ export interface IGitAuthor {
|
||||
lineCount: number;
|
||||
}
|
||||
|
||||
export interface IGitCommit {
|
||||
interface IGitCommit {
|
||||
repoPath: string;
|
||||
sha: string;
|
||||
fileName: string;
|
||||
@@ -57,10 +57,20 @@ export class GitCommit implements IGitCommit {
|
||||
originalFileName?: string;
|
||||
previousSha?: string;
|
||||
previousFileName?: string;
|
||||
private _isUncommitted: boolean|undefined;
|
||||
private _isUncommitted: boolean | undefined;
|
||||
|
||||
constructor(public repoPath: string, public sha: string, public fileName: string, public author: string, public date: Date, public message: string,
|
||||
lines?: IGitCommitLine[], originalFileName?: string, previousSha?: string, previousFileName?: string) {
|
||||
constructor(
|
||||
public repoPath: string,
|
||||
public sha: string,
|
||||
public fileName: string,
|
||||
public author: string,
|
||||
public date: Date,
|
||||
public message: string,
|
||||
lines?: IGitCommitLine[],
|
||||
originalFileName?: string,
|
||||
previousSha?: string,
|
||||
previousFileName?: string
|
||||
) {
|
||||
this.lines = lines || [];
|
||||
this.originalFileName = originalFileName;
|
||||
this.previousSha = previousSha;
|
||||
@@ -94,5 +104,5 @@ export interface IGitCommitLine {
|
||||
export interface IGitLog {
|
||||
repoPath: string;
|
||||
authors: Map<string, IGitAuthor>;
|
||||
commits: Map<string, IGitCommit>;
|
||||
commits: Map<string, GitCommit>;
|
||||
}
|
||||
Reference in New Issue
Block a user