瀏覽代碼

Closes #431 - adds tag annotations to tooltips

main
Eric Amodio 6 年之前
父節點
當前提交
bfbefd03ca
共有 8 個檔案被更改,包括 66 行新增13 行删除
  1. +1
    -0
      CHANGELOG.md
  2. +1
    -1
      src/git/git.ts
  3. +2
    -1
      src/git/models/tag.ts
  4. +14
    -1
      src/git/parsers/branchParser.ts
  5. +12
    -3
      src/git/parsers/diffParser.ts
  6. +15
    -5
      src/git/parsers/remoteParser.ts
  7. +20
    -2
      src/git/parsers/tagParser.ts
  8. +1
    -0
      src/views/tagNode.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 the ability to show the *GitLens*, *GitLens File History*, and *GitLens Results* explorers in an all-new *GitLens* view (in addition to the existing locations)
- Adds tag annotations to the tag tooltips in the *GitLens* explorer — closes [#431](https://github.com/eamodio/vscode-gitlens/issues/431)
- Adds `gitlens.hovers.avatars` setting to specify whether to show avatar images in hovers — closes [#432](https://github.com/eamodio/vscode-gitlens/issues/432) thanks to [PR #441](https://github.com/eamodio/vscode-gitlens/pull/441) by Segev Finer ([@segevfiner](https://github.com/segevfiner))
- Adds `gitlens.hovers.avatars` setting to the interactive settings editor to specify whether to show avatar images in hovers

+ 1
- 1
src/git/git.ts 查看文件

@ -731,7 +731,7 @@ export class Git {
}
static tag(repoPath: string) {
const params = ['tag', '-l'];
const params = ['tag', '-l', '-n1'];
return gitCommand({ cwd: repoPath }, ...params);
}

+ 2
- 1
src/git/models/tag.ts 查看文件

@ -3,7 +3,8 @@
export class GitTag {
constructor(
public readonly repoPath: string,
public readonly name: string
public readonly name: string,
public readonly annotation?: string
) {}
private _basename: string | undefined;

+ 14
- 1
src/git/parsers/branchParser.ts 查看文件

@ -16,7 +16,20 @@ export class GitBranchParser {
if (match == null) break;
const [ahead, behind] = this.parseState(match[5]);
branches.push(new GitBranch(repoPath, match[2], match[1] === '*', match[3], match[4], ahead, behind));
branches.push(
new GitBranch(
repoPath,
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
(' ' + match[2]).substr(1),
match[1] === '*',
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
match[3] === undefined ? undefined : (' ' + match[3]).substr(1),
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
match[4] === undefined ? undefined : (' ' + match[4]).substr(1),
ahead,
behind
)
);
} while (match != null);
if (!branches.length) return undefined;

+ 12
- 3
src/git/parsers/diffParser.ts 查看文件

@ -30,8 +30,7 @@ export class GitDiffParser {
match = unifiedDiffRegex.exec(`${data}\n@@`);
if (match == null) break;
// Stops excessive memory usage
// https://bugs.chromium.org/p/v8/issues/detail?id=2869
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
chunk = (' ' + match[5]).substr(1);
currentStart = parseInt(match[3], 10);
previousStart = parseInt(match[1], 10);
@ -148,7 +147,17 @@ export class GitDiffParser {
match = nameStatusDiffRegex.exec(data);
if (match == null) break;
statuses.push(GitStatusParser.parseStatusFile(repoPath, match[1], match[2], match[3]));
statuses.push(
GitStatusParser.parseStatusFile(
repoPath,
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
(' ' + match[1]).substr(1),
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
(' ' + match[2]).substr(1),
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
match[3] === undefined ? undefined : (' ' + match[3]).substr(1)
)
);
} while (match != null);
if (!statuses.length) return undefined;

+ 15
- 5
src/git/parsers/remoteParser.ts 查看文件

@ -59,21 +59,31 @@ export class GitRemoteParser {
match = remoteRegex.exec(data);
if (match == null) break;
const url = match[2];
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
const url = (' ' + match[2]).substr(1);
const [scheme, domain, path] = this.parseGitUrl(url);
const uniqueness = `${domain}/${path}`;
let remote: GitRemote | undefined = groups[uniqueness];
if (remote === undefined) {
remote = new GitRemote(repoPath, match[1], scheme, domain, path, providerFactory(domain, path), [
{ url: url, type: match[3] as GitRemoteType }
]);
remote = new GitRemote(
repoPath,
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
(' ' + match[1]).substr(1),
scheme,
domain,
path,
providerFactory(domain, path),
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
[{ url: url, type: (' ' + match[3]).substr(1) as GitRemoteType }]
);
remotes.push(remote);
groups[uniqueness] = remote;
}
else {
remote.types.push({ url: url, type: match[3] as GitRemoteType });
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
remote.types.push({ url: url, type: (' ' + match[3]).substr(1) as GitRemoteType });
}
} while (match != null);

+ 20
- 2
src/git/parsers/tagParser.ts 查看文件

@ -1,12 +1,30 @@
'use strict';
import { Arrays } from '../../system';
import { GitTag } from './../git';
const tagWithAnnotationRegex = /^(.+?)(?:$|(?:\s+)(.*)$)/gm;
export class GitTagParser {
static parse(data: string, repoPath: string): GitTag[] | undefined {
if (!data) return undefined;
const tags = Arrays.filterMap(data.split('\n'), t => (!!t ? new GitTag(repoPath, t) : undefined));
const tags: GitTag[] = [];
let match: RegExpExecArray | null = null;
do {
match = tagWithAnnotationRegex.exec(data);
if (match == null) break;
tags.push(
new GitTag(
repoPath,
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
(' ' + match[1]).substr(1),
// Stops excessive memory usage -- https://bugs.chromium.org/p/v8/issues/detail?id=2869
match[2] === undefined ? undefined : (' ' + match[2]).substr(1)
)
);
} while (match != null);
if (!tags.length) return undefined;
return tags;

+ 1
- 0
src/views/tagNode.ts 查看文件

@ -45,6 +45,7 @@ export class TagNode extends ExplorerRefNode {
async getTreeItem(): Promise<TreeItem> {
const item = new TreeItem(this.label, TreeItemCollapsibleState.Collapsed);
item.tooltip = `${this.tag.name}${this.tag.annotation === undefined ? '' : `\n${this.tag.annotation}`}`;
item.contextValue = ResourceType.Tag;
return item;
}

Loading…
取消
儲存