mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-16 17:25:40 -05:00
Fixes issues with merge commits
This commit is contained in:
@@ -14,8 +14,8 @@ export * from './remotes/provider';
|
||||
|
||||
let git: IGit;
|
||||
|
||||
//`--format=%H -%nauthor %an%nauthor-date %ai%ncommitter %cn%ncommitter-date %ci%nparent %P%nsummary %B%nfilename ?`
|
||||
const defaultLogParams = [`log`, `--name-status`, `--full-history`, `-M`, `--date=iso8601-strict`, `--format=%H -%nauthor %an%nauthor-date %ai%nsummary %B%nfilename ?`];
|
||||
// `--format=%H -%nauthor %an%nauthor-date %ai%ncommitter %cn%ncommitter-date %ci%nparents %P%nsummary %B%nfilename ?`
|
||||
const defaultLogParams = [`log`, `--name-status`, `--full-history`, `-M`, `--date=iso8601-strict`, `--format=%H -%nauthor %an%nauthor-date %ai%nparents %P%nsummary %B%nfilename ?`];
|
||||
|
||||
async function gitCommand(cwd: string, ...args: any[]) {
|
||||
try {
|
||||
@@ -166,7 +166,7 @@ export class Git {
|
||||
}
|
||||
|
||||
static log(repoPath: string, sha?: string, maxCount?: number, reverse: boolean = false) {
|
||||
const params = [...defaultLogParams];
|
||||
const params = [...defaultLogParams, `-m`];
|
||||
if (maxCount && !reverse) {
|
||||
params.push(`-n${maxCount}`);
|
||||
}
|
||||
@@ -186,10 +186,19 @@ export class Git {
|
||||
static log_file(repoPath: string, fileName: string, sha?: string, maxCount?: number, reverse: boolean = false, startLine?: number, endLine?: number) {
|
||||
const [file, root] = Git.splitPath(fileName, repoPath);
|
||||
|
||||
const params = [...defaultLogParams, `--no-merges`, `--follow`];
|
||||
const params = [...defaultLogParams, `--follow`];
|
||||
if (maxCount && !reverse) {
|
||||
params.push(`-n${maxCount}`);
|
||||
}
|
||||
|
||||
// If we are looking for a specific sha don't exclude merge commits
|
||||
if (!sha || maxCount > 2) {
|
||||
params.push(`--no-merges`);
|
||||
}
|
||||
else {
|
||||
params.push(`-m`);
|
||||
}
|
||||
|
||||
if (sha) {
|
||||
if (reverse) {
|
||||
params.push(`--reverse`);
|
||||
|
||||
@@ -12,6 +12,7 @@ export class GitLogCommit extends GitCommit {
|
||||
fileStatuses: { status: GitStatusFileStatus, fileName: string, originalFileName?: string }[];
|
||||
nextSha?: string;
|
||||
nextFileName?: string;
|
||||
parentShas: string[];
|
||||
status: GitStatusFileStatus;
|
||||
|
||||
constructor(
|
||||
@@ -43,6 +44,10 @@ export class GitLogCommit extends GitCommit {
|
||||
}
|
||||
}
|
||||
|
||||
get isMerge() {
|
||||
return this.parentShas && this.parentShas.length > 1;
|
||||
}
|
||||
|
||||
get nextShortSha() {
|
||||
return this.nextSha && this.nextSha.substring(0, 8);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ interface ILogEntry {
|
||||
// committer?: string;
|
||||
// committerDate?: string;
|
||||
|
||||
// parentSha?: string;
|
||||
parentShas?: string[];
|
||||
|
||||
fileName?: string;
|
||||
originalFileName?: string;
|
||||
@@ -75,9 +75,9 @@ export class GitLogParser {
|
||||
// entry.committerDate = lineParts.slice(1).join(' ').trim();
|
||||
// break;
|
||||
|
||||
// case 'parent':
|
||||
// entry.parentSha = lineParts.slice(1).join(' ').trim();
|
||||
// break;
|
||||
case 'parents':
|
||||
entry.parentShas = lineParts.slice(1);
|
||||
break;
|
||||
|
||||
case 'summary':
|
||||
entry.summary = lineParts.slice(1).join(' ').trim();
|
||||
@@ -227,6 +227,7 @@ export class GitLogParser {
|
||||
}
|
||||
|
||||
commit = new GitLogCommit(type, repoPath, entry.sha, relativeFileName, entry.author, moment(entry.authorDate).toDate(), entry.summary, entry.status, entry.fileStatuses, undefined, entry.originalFileName);
|
||||
commit.parentShas = entry.parentShas;
|
||||
|
||||
if (relativeFileName !== entry.fileName) {
|
||||
commit.originalFileName = entry.fileName;
|
||||
|
||||
Reference in New Issue
Block a user