Switches to porcelain blame format

Provides more data (commit message, previous commit, etc)
This commit is contained in:
Eric Amodio
2016-09-04 03:43:35 -04:00
parent 47ce5c5132
commit ebb1085562
3 changed files with 159 additions and 38 deletions

View File

@@ -23,7 +23,7 @@ export default class Git {
if (sha) {
console.log('git', 'blame', '-fn', '--root', `${sha}^`, '--', fileName);
return gitCommand(repoPath, 'blame', '-fnw', '--root', `${sha}^`, '--', fileName);
return gitCommand(repoPath, 'blame', '-fn', '--root', `${sha}^`, '--', fileName);
}
console.log('git', 'blame', '-fn', '--root', '--', fileName);
@@ -32,6 +32,20 @@ export default class Git {
// .catch(ex => console.error(ex));
}
static blamePorcelain(fileName: string, repoPath: string, sha?: string) {
fileName = Git.normalizePath(fileName, repoPath);
if (sha) {
console.log('git', 'blame', '--porcelain', '--root', `${sha}^`, '--', fileName);
return gitCommand(repoPath, 'blame', '--porcelain', '--root', `${sha}^`, '--', fileName);
}
console.log('git', 'blame', '--porcelain', '--root', '--', fileName);
return gitCommand(repoPath, 'blame', '--porcelain', '--root', '--', fileName);
// .then(s => { console.log(s); return s; })
// .catch(ex => console.error(ex));
}
static getVersionedFile(fileName: string, repoPath: string, sha: string) {
return new Promise<string>((resolve, reject) => {
Git.getVersionedFileText(fileName, repoPath, sha).then(data => {
@@ -79,6 +93,7 @@ export default class Git {
static getCommitMessages(fileName: string, repoPath: string) {
fileName = Git.normalizePath(fileName, repoPath);
// git log --format="%h (%aN %x09 %ai) %s" --
console.log('git', 'log', '--oneline', '--', fileName);
return gitCommand(repoPath, 'log', '--oneline', '--', fileName);
// .then(s => { console.log(s); return s; })