diff --git a/package.json b/package.json index b0962113..59656404 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "compile": "node ./node_modules/vscode/bin/compile -watch -p ./" }, "dependencies": { - "git-blame": "^0.1.1", + "git-blame": "^1.1.0", "moment": "^2.10.6", "path": "^0.12.7", "typescript": "^1.6.2", @@ -46,6 +46,26 @@ "commands": [{ "command": "extension.blame", "title": "Git Blame" - }] + }], + "configuration": { + "title": "Git Blame configuration", + "properties": { + "git-blame.ignore-whitespace-change":{ + "type": "boolean", + "default": true, + "description" : "If set to true, git blame command will ignore any whitespace change applied to currently selected line" + }, + "git-blame.status-message":{ + "type": "string", + "default": "Blame %s ( %s )", + "description" : "Output message shown in status bar" + }, + "git-blame.popup-message":{ + "type": "string", + "default": "%s %s", + "description": "Output message shown in tooltip bar" + } + } + } } } diff --git a/src/controller.ts b/src/controller.ts index 4bcf6b32..fbf14817 100644 --- a/src/controller.ts +++ b/src/controller.ts @@ -1,5 +1,5 @@ -import {Disposable, window, TextEditor, TextEditorSelectionChangeEvent} from 'vscode'; +import {Disposable, window, TextEditor, TextEditorSelectionChangeEvent, workspace} from 'vscode'; import {GitBlame} from './gitblame'; import * as path from 'path'; import * as moment from 'moment'; @@ -75,7 +75,7 @@ export class TextDecorator { const author = commit['author']; const dateText = this.toDateText(dateNow, new Date(author['timestamp'] * 1000)); - return 'Blame ' + author['name'] + ' ( ' + dateText + ' )'; + return require('util').format(workspace.getConfiguration('git-blame').get('status-message', 'Blame %s ( %s )'), author['name'], dateText); } toDateText(dateNow: Date, dateThen: Date) : string { diff --git a/src/extension.ts b/src/extension.ts index e5e5f617..ff181d1f 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -80,7 +80,7 @@ function showMessage(context: ExtensionContext, repoDir: string) { const hash = info['lines'][lineNumber]['hash']; const commitInfo = info['commits'][hash]; - window.showInformationMessage(hash + ' ' + commitInfo['summary']); + window.showInformationMessage(require('util').format(workspace.getConfiguration('git-blame').get('popup-message', '%s %s'), hash, commitInfo['summary'])); } }); } diff --git a/src/gitblame.ts b/src/gitblame.ts index 86a77be4..78741cbd 100644 --- a/src/gitblame.ts +++ b/src/gitblame.ts @@ -1,4 +1,4 @@ - +import * as vscode from 'vscode'; export class GitBlame { @@ -38,7 +38,8 @@ export class GitBlame { }; self.gitBlameProcess(repo, { - file: fileName + file: fileName, + ignoreWhitespaces: vscode.workspace.getConfiguration('git-blame').get("ignore-whitespace-change", true) }).on('data', (type, data) => { // outputs in Porcelain format. if (type === 'line') {