diff --git a/CHANGELOG.md b/CHANGELOG.md index 92828ff..7cc480a 100644 --- a/CHANGELOG.md +++ b/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 diff --git a/src/git/git.ts b/src/git/git.ts index ad536dc..34c6091 100644 --- a/src/git/git.ts +++ b/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); } diff --git a/src/git/models/tag.ts b/src/git/models/tag.ts index 063b172..f7aafcd 100644 --- a/src/git/models/tag.ts +++ b/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; diff --git a/src/git/parsers/branchParser.ts b/src/git/parsers/branchParser.ts index 87ead28..ffb80e8 100644 --- a/src/git/parsers/branchParser.ts +++ b/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; diff --git a/src/git/parsers/diffParser.ts b/src/git/parsers/diffParser.ts index 14fc9fd..87eaafb 100644 --- a/src/git/parsers/diffParser.ts +++ b/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; diff --git a/src/git/parsers/remoteParser.ts b/src/git/parsers/remoteParser.ts index 6dbe3ff..35e3bd1 100644 --- a/src/git/parsers/remoteParser.ts +++ b/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); diff --git a/src/git/parsers/tagParser.ts b/src/git/parsers/tagParser.ts index 9d3f66a..3a3b311 100644 --- a/src/git/parsers/tagParser.ts +++ b/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; diff --git a/src/views/tagNode.ts b/src/views/tagNode.ts index cbb8df7..907fe48 100644 --- a/src/views/tagNode.ts +++ b/src/views/tagNode.ts @@ -45,6 +45,7 @@ export class TagNode extends ExplorerRefNode { async getTreeItem(): Promise { 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; }