Bläddra i källkod

Adds proper support for multiline commit messages

Fixes #33 - commit messages needs to be escaped
main
Eric Amodio 7 år sedan
förälder
incheckning
ccd0ad67a3
3 ändrade filer med 7 tillägg och 3 borttagningar
  1. +2
    -2
      src/blameAnnotationFormatter.ts
  2. +4
    -0
      src/git/enrichers/logParserEnricher.ts
  3. +1
    -1
      src/git/git.ts

+ 2
- 2
src/blameAnnotationFormatter.ts Visa fil

@ -65,12 +65,12 @@ export default class BlameAnnotationFormatter {
}
static getAnnotationHover(config: IBlameConfig, line: IGitCommitLine, commit: GitCommit): string | Array<string> {
const message = commit.message.replace(/\n/g, '\n\n');
const message = `> \`${commit.message.replace(/\n/g, '\`\n>\n> \`')}\``;
if (commit.isUncommitted) {
return `\`${'0'.repeat(8)}\` &nbsp; __Uncommitted changes__`;
}
return `\`${commit.sha}\` &nbsp; __${commit.author}__, ${moment(commit.date).fromNow()} _(${moment(commit.date).format('MMMM Do, YYYY h:MMa')})_ \n\n > ${message}`;
return `\`${commit.sha}\` &nbsp; __${commit.author}__, ${moment(commit.date).fromNow()} _(${moment(commit.date).format('MMMM Do, YYYY h:MMa')})_ \n\n${message}`;
}
static getAuthorAndDate(config: IBlameConfig, commit: GitCommit, format?: string, force: boolean = false) {

+ 4
- 0
src/git/enrichers/logParserEnricher.ts Visa fil

@ -68,6 +68,10 @@ export class GitLogParserEnricher implements IGitEnricher {
case 'summary':
entry.summary = lineParts.slice(1).join(' ').trim();
while (++position < lines.length) {
if (!lines[position]) break;
entry.summary += `\n${lines[position]}`;
}
break;
case 'filename':

+ 1
- 1
src/git/git.ts Visa fil

@ -13,7 +13,7 @@ export * from './enrichers/logParserEnricher';
let git: IGit;
const UncommittedRegex = /^[0]+$/;
const DefaultLogParams = [`log`, `--name-status`, `--full-history`, `-m`, `--date=iso8601-strict`, `--format=%H -%nauthor %an%nauthor-date %ai%ncommitter %cn%ncommitter-date %ci%nsummary %s%nfilename ?`];
const DefaultLogParams = [`log`, `--name-status`, `--full-history`, `-m`, `--date=iso8601-strict`, `--format=%H -%nauthor %an%nauthor-date %ai%ncommitter %cn%ncommitter-date %ci%nsummary %B%nfilename ?`];
async function gitCommand(cwd: string, ...args: any[]) {
try {

Laddar…
Avbryt
Spara