Attempted fix for bad filename to diff w/ working

Tried to find the most recent filename given a commit, but git doesn't seem to want to cooperate
This commit is contained in:
Eric Amodio
2017-02-13 13:19:55 -05:00
parent d5d0c3a28d
commit 5f147f6262
5 changed files with 50 additions and 14 deletions

View File

@@ -109,7 +109,7 @@ export class GitLogParserEnricher implements IGitEnricher<IGitLog> {
return entries;
}
enrich(data: string, fileNameOrRepoPath: string, isRepoPath: boolean = false): IGitLog {
enrich(data: string, type: 'file' | 'repo', fileNameOrRepoPath: string, isRepoPath: boolean = false): IGitLog {
const entries = this._parseEntries(data, isRepoPath);
if (!entries) return undefined;
@@ -160,7 +160,10 @@ export class GitLogParserEnricher implements IGitEnricher<IGitLog> {
if (recentCommit) {
recentCommit.previousSha = commit.sha;
recentCommit.previousFileName = commit.originalFileName || commit.fileName;
// Only add a filename if this is a file log
if (type === 'file') {
recentCommit.previousFileName = commit.originalFileName || commit.fileName;
}
}
recentCommit = commit;
}

View File

@@ -87,7 +87,7 @@ export default class Git {
return gitCommand(root, ...params, `--`, file);
}
static log(fileName: string, sha?: string, repoPath?: string, maxCount?: number) {
static log(fileName: string, sha?: string, repoPath?: string, maxCount?: number, reverse: boolean = false) {
const [file, root]: [string, string] = Git.splitPath(Git.normalizePath(fileName), repoPath);
const params = [...DefaultLogParams, `--follow`];
@@ -95,7 +95,12 @@ export default class Git {
params.push(`-n${maxCount}`);
}
if (sha) {
params.push(sha);
if (reverse) {
params.push(`${sha}..HEAD`);
}
else {
params.push(sha);
}
params.push(`--`);
}