瀏覽代碼

Adds proper support for multiline commit messages

Fixes #33 - commit messages needs to be escaped
main
Eric Amodio 7 年之前
父節點
當前提交
ccd0ad67a3
共有 3 個檔案被更改,包括 7 行新增3 行删除
  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 查看文件

@ -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 查看文件

@ -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 查看文件

@ -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 {

Loading…
取消
儲存