浏览代码

Closes #337 - adds custom args for blame

main
Eric Amodio 6 年前
父节点
当前提交
9c5c5bf3b4
共有 6 个文件被更改,包括 58 次插入6 次删除
  1. +1
    -0
      CHANGELOG.md
  2. +1
    -0
      README.md
  3. +6
    -0
      package.json
  4. +8
    -2
      src/git/git.ts
  5. +41
    -4
      src/gitService.ts
  6. +1
    -0
      src/ui/config.ts

+ 1
- 0
CHANGELOG.md 查看文件

@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased]
### Added
- Adds an indicator to the *GitLens* explorer's branch history to mark the the tips of all branches
- Adds `gitlens.advanced.blame.customArguments` setting to specify additional arguments to pass to the `git blame` command — closes [#337](https://github.com/eamodio/vscode-gitlens/issues/337)
### Changed
- Changes the author name to "You" when appropriate — closes [#341](https://github.com/eamodio/vscode-gitlens/issues/341)

+ 1
- 0
README.md 查看文件

@ -691,6 +691,7 @@ See also [Explorer Settings](#explorer-settings "Jump to the Explorer settings")
|Name | Description
|-----|------------
|`gitlens.advanced.blame.customArguments`|Specifies additional arguments to pass to the `git blame` command
|`gitlens.advanced.blame.delayAfterEdit`|Specifies the time (in milliseconds) to wait before re-blaming an unsaved document after an edit. Use 0 to specify an infinite wait
|`gitlens.advanced.blame.sizeThresholdAfterEdit`|Specifies the maximum document size (in lines) allowed to be re-blamed after an edit while still unsaved. Use 0 to specify no maximum
|`gitlens.advanced.caching.enabled`|Specifies whether git output will be cached — changing the default is not recommended

+ 6
- 0
package.json 查看文件

@ -809,6 +809,12 @@
"description": "Specifies the string to be shown in place of the `authors` code lens when there are unsaved changes",
"scope": "window"
},
"gitlens.advanced.blame.customArguments": {
"type": "string[]",
"default": null,
"description": "Specifies additional arguments to pass to the `git blame` command",
"scope": "resource"
},
"gitlens.advanced.blame.delayAfterEdit": {
"type": "number",
"default": 5000,

+ 8
- 2
src/git/git.ts 查看文件

@ -267,7 +267,7 @@ export class Git {
// Git commands
static async blame(repoPath: string | undefined, fileName: string, sha?: string, options: { ignoreWhitespace?: boolean, startLine?: number, endLine?: number } = {}) {
static async blame(repoPath: string | undefined, fileName: string, sha?: string, options: { args?: string[] | null, ignoreWhitespace?: boolean, startLine?: number, endLine?: number } = {}) {
const [file, root] = Git.splitPath(fileName, repoPath);
const params = [...defaultBlameParams];
@ -278,6 +278,9 @@ export class Git {
if (options.startLine != null && options.endLine != null) {
params.push(`-L ${options.startLine},${options.endLine}`);
}
if (options.args != null) {
params.push(...options.args);
}
let stdin;
if (sha) {
@ -296,7 +299,7 @@ export class Git {
return gitCommand({ cwd: root, stdin: stdin }, ...params, '--', file);
}
static async blame_contents(repoPath: string | undefined, fileName: string, contents: string, options: { correlationKey?: string, ignoreWhitespace?: boolean, startLine?: number, endLine?: number } = {}) {
static async blame_contents(repoPath: string | undefined, fileName: string, contents: string, options: { args?: string[] | null, correlationKey?: string, ignoreWhitespace?: boolean, startLine?: number, endLine?: number } = {}) {
const [file, root] = Git.splitPath(fileName, repoPath);
const params = [...defaultBlameParams];
@ -307,6 +310,9 @@ export class Git {
if (options.startLine != null && options.endLine != null) {
params.push(`-L ${options.startLine},${options.endLine}`);
}
if (options.args != null) {
params.push(...options.args);
}
// Pipe the blame contents to stdin
params.push('--contents', '-');

+ 41
- 4
src/gitService.ts 查看文件

@ -456,7 +456,15 @@ export class GitService extends Disposable {
const [file, root] = Git.splitPath(uri.fsPath, uri.repoPath, false);
try {
const data = await Git.blame(root, file, uri.sha, { ignoreWhitespace: Container.config.blame.ignoreWhitespace });
const data = await Git.blame(
root,
file,
uri.sha,
{
args: Container.config.advanced.blame.customArguments,
ignoreWhitespace: Container.config.blame.ignoreWhitespace
}
);
const blame = GitBlameParser.parse(data, root, file, await this.getCurrentUsername(root));
return blame;
}
@ -525,7 +533,16 @@ export class GitService extends Disposable {
const [file, root] = Git.splitPath(uri.fsPath, uri.repoPath, false);
try {
const data = await Git.blame_contents(root, file, contents, { correlationKey: `:${key}`, ignoreWhitespace: Container.config.blame.ignoreWhitespace });
const data = await Git.blame_contents(
root,
file,
contents,
{
args: Container.config.advanced.blame.customArguments,
correlationKey: `:${key}`,
ignoreWhitespace: Container.config.blame.ignoreWhitespace
}
);
const blame = GitBlameParser.parse(data, root, file, await this.getCurrentUsername(root));
return blame;
}
@ -575,7 +592,17 @@ export class GitService extends Disposable {
const fileName = uri.fsPath;
try {
const data = await Git.blame(uri.repoPath, fileName, uri.sha, { ignoreWhitespace: Container.config.blame.ignoreWhitespace, startLine: lineToBlame, endLine: lineToBlame });
const data = await Git.blame(
uri.repoPath,
fileName,
uri.sha,
{
args: Container.config.advanced.blame.customArguments,
ignoreWhitespace: Container.config.blame.ignoreWhitespace,
startLine: lineToBlame,
endLine: lineToBlame
}
);
const blame = GitBlameParser.parse(data, uri.repoPath, fileName, await this.getCurrentUsername(uri.repoPath!));
if (blame === undefined) return undefined;
@ -617,7 +644,17 @@ export class GitService extends Disposable {
const fileName = uri.fsPath;
try {
const data = await Git.blame_contents(uri.repoPath, fileName, contents, { ignoreWhitespace: Container.config.blame.ignoreWhitespace, startLine: lineToBlame, endLine: lineToBlame });
const data = await Git.blame_contents(
uri.repoPath,
fileName,
contents,
{
args: Container.config.advanced.blame.customArguments,
ignoreWhitespace: Container.config.blame.ignoreWhitespace,
startLine: lineToBlame,
endLine: lineToBlame
}
);
const currentUser = await this.getCurrentUsername(uri.repoPath!);
const blame = GitBlameParser.parse(data, uri.repoPath, fileName, currentUser);
if (blame === undefined) return undefined;

+ 1
- 0
src/ui/config.ts 查看文件

@ -103,6 +103,7 @@ export enum StatusBarCommand {
export interface IAdvancedConfig {
blame: {
customArguments: string[] | null;
delayAfterEdit: number;
sizeThresholdAfterEdit: number;
};

正在加载...
取消
保存