Skip to content

Commit 6658285

Browse files
committed
Adds customization for hovers + email link - closes #642
Adds author email to commit node tooltips Adds ${email} token to many formats
1 parent 1ac1e9e commit 6658285

File tree

7 files changed

+190
-146
lines changed

7 files changed

+190
-146
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- Adds a `mailto:` link to the author on the _commit details_ hover — closes [#642](https://github.com/eamodio/vscode-gitlens/issues/642)
12+
- Adds support for customizing the layout of the _commit details_ hover
13+
- Adds a `gitlens.hovers.detailsMarkdownFormat` setting to specify the format (in markdown) of the _commit details_ hover
14+
- Adds the author's e-mail to the tooltip of commits in the views — closes [#642](https://github.com/eamodio/vscode-gitlens/issues/642)
15+
- Adds an `${email}` token (author e-mail) to `gitlens.blame.format`, `gitlens.currentLine.format`, `gitlens.hovers.detailsMarkdownFormat`, `gitlens.views.commitFormat`, `gitlens.views.commitDescriptionFormat`, `gitlens.views.stashFormat`, `gitlens.views.stashDescriptionFormat`, and `gitlens.statusBar.format` settings — closes [#642](https://github.com/eamodio/vscode-gitlens/issues/642)
16+
917
### Changed
1018

1119
- Changes the sorting of remotes in the _Repositories_ view to sort the default remote first

README.md

Lines changed: 54 additions & 53 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"gitlens.blame.format": {
7575
"type": "string",
7676
"default": "${message|40?} ${agoOrDate|14-}",
77-
"markdownDescription": "Specifies the format of the gutter blame annotations. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.blame.dateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
77+
"markdownDescription": "Specifies the format of the gutter blame annotations. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${email}` — commit author e-mail\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.blame.dateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
7878
"scope": "window"
7979
},
8080
"gitlens.blame.heatmap.enabled": {
@@ -398,7 +398,7 @@
398398
"gitlens.currentLine.format": {
399399
"type": "string",
400400
"default": "${authorAgoOrDate} • ${message}",
401-
"markdownDescription": "Specifies the format of the current line blame annotation. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.currentLine.dateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
401+
"markdownDescription": "Specifies the format of the current line blame annotation. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${email}` — commit author e-mail\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.currentLine.dateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
402402
"scope": "window"
403403
},
404404
"gitlens.currentLine.scrollable": {
@@ -563,6 +563,12 @@
563563
"markdownDescription": "Specifies whether to show avatar images in hovers",
564564
"scope": "window"
565565
},
566+
"gitlens.hovers.detailsMarkdownFormat": {
567+
"type": "string",
568+
"default": "[${avatar}  __${author}__](mailto:${email}), ${ago}   _(${date})_ ${message}\n\n${commands}",
569+
"markdownDescription": "Specifies the format (in markdown) of the _commit details_ hover. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${email}` — commit author e-mail\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`\n - `${avatar}` — commit author avatar\n - `${commands}` — a set of commit commands",
570+
"scope": "window"
571+
},
566572
"gitlens.hovers.enabled": {
567573
"type": "boolean",
568574
"default": true,
@@ -1216,7 +1222,7 @@
12161222
"gitlens.statusBar.format": {
12171223
"type": "string",
12181224
"default": "${authorAgoOrDate}",
1219-
"markdownDescription": "Specifies the format of the gutter blame annotations. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.statusBar.dateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
1225+
"markdownDescription": "Specifies the format of the gutter blame annotations. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${email}` — commit author e-mail\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.statusBar.dateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
12201226
"scope": "window"
12211227
},
12221228
"gitlens.statusBar.reduceFlicker": {
@@ -1258,13 +1264,13 @@
12581264
"gitlens.views.commitFormat": {
12591265
"type": "string",
12601266
"default": "${message}",
1261-
"markdownDescription": "Specifies the format of committed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
1267+
"markdownDescription": "Specifies the format of committed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${email}` — commit author e-mail\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
12621268
"scope": "window"
12631269
},
12641270
"gitlens.views.commitDescriptionFormat": {
12651271
"type": "string",
12661272
"default": "${changes • }${authorAgoOrDate}",
1267-
"markdownDescription": "Specifies the description format of committed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
1273+
"markdownDescription": "Specifies the description format of committed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${email}` — commit author e-mail\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
12681274
"scope": "window"
12691275
},
12701276
"gitlens.views.compare.avatars": {
@@ -1562,13 +1568,13 @@
15621568
"gitlens.views.stashFormat": {
15631569
"type": "string",
15641570
"default": "${message}",
1565-
"markdownDescription": "Specifies the format of stashed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.statusBar.dateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
1571+
"markdownDescription": "Specifies the format of stashed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${email}` — commit author e-mail\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
15661572
"scope": "window"
15671573
},
15681574
"gitlens.views.stashDescriptionFormat": {
15691575
"type": "string",
15701576
"default": "${changes • }${agoOrDate}",
1571-
"markdownDescription": "Specifies the description format of stashed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.statusBar.dateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
1577+
"markdownDescription": "Specifies the description format of stashed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${email}` — commit author e-mail\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
15721578
"scope": "window"
15731579
},
15741580
"gitlens.views.statusFileFormat": {

src/annotations/annotations.ts

Lines changed: 7 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -86,42 +86,6 @@ export class Annotations {
8686
return `rgba(${computedHeatmapColor.rgb}, ${(1 - age / 10).toFixed(2)})`;
8787
}
8888

89-
private static getHoverCommandBar(
90-
commit: GitCommit,
91-
hasRemote: boolean,
92-
annotationType?: FileAnnotationType,
93-
line: number = 0
94-
) {
95-
let commandBar = `[\`${GlyphChars.MuchGreaterThan}\`](${DiffWithCommand.getMarkdownCommandArgs(
96-
commit
97-
)} "Open Changes") `;
98-
99-
if (commit.previousSha !== undefined) {
100-
if (annotationType === FileAnnotationType.RecentChanges) {
101-
annotationType = FileAnnotationType.Blame;
102-
}
103-
104-
const uri = GitUri.toRevisionUri(commit.previousSha, commit.previousUri.fsPath, commit.repoPath);
105-
commandBar += `[\`${GlyphChars.SquareWithTopShadow}\`](${OpenFileRevisionCommand.getMarkdownCommandArgs(
106-
uri,
107-
annotationType || FileAnnotationType.Blame,
108-
line
109-
)} "Blame Previous Revision") `;
110-
}
111-
112-
if (hasRemote) {
113-
commandBar += `[\`${GlyphChars.ArrowUpRight}\`](${OpenCommitInRemoteCommand.getMarkdownCommandArgs(
114-
commit.sha
115-
)} "Open in Remote") `;
116-
}
117-
118-
commandBar += `[\`${GlyphChars.MiddleEllipsis}\`](${ShowQuickCommitFileDetailsCommand.getMarkdownCommandArgs(
119-
commit.sha
120-
)} "Show More Actions")`;
121-
122-
return commandBar;
123-
}
124-
12589
static getHoverMessage(
12690
commit: GitCommit,
12791
dateFormat: string | null,
@@ -133,51 +97,14 @@ export class Annotations {
13397
dateFormat = 'MMMM Do, YYYY h:mma';
13498
}
13599

136-
let message = '';
137-
let commandBar = '';
138-
let showCommitDetailsCommand = '';
139-
let avatar = '';
140-
if (!commit.isUncommitted) {
141-
commandBar = `\n\n${this.getHoverCommandBar(commit, remotes.length !== 0, annotationType, line)}`;
142-
showCommitDetailsCommand = `[\`${commit.shortSha}\`](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(
143-
commit.sha
144-
)} "Show Commit Details")`;
145-
146-
message = CommitFormatter.fromTemplate('${message}', commit);
147-
148-
remotes.sort(
149-
(a, b) =>
150-
(a.default ? -1 : 1) - (b.default ? -1 : 1) ||
151-
a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' })
152-
);
153-
154-
for (const r of remotes) {
155-
if (r.provider === undefined) continue;
156-
157-
message = r.provider.enrichMessage(message);
158-
break;
159-
}
160-
161-
message = `\n\n> ${message
162-
// Escape markdown
163-
.replace(escapeMarkdownRegex, '\\$&')
164-
// Escape markdown header (since the above regex won't match it)
165-
.replace(/^===/gm, markdownHeaderReplacement)
166-
// Keep under the same block-quote but with line breaks
167-
.replace(/\n/g, '\t\n> ')}`;
168-
}
169-
else {
170-
showCommitDetailsCommand = `\`${commit.shortSha === 'Working Tree' ? '00000000' : commit.shortSha}\``;
171-
}
172-
173-
if (Container.config.hovers.avatars) {
174-
avatar = `   ![](${commit.getGravatarUri(Container.config.defaultGravatarsStyle).toString(true)})`;
175-
}
176-
177100
const markdown = new MarkdownString(
178-
`${showCommitDetailsCommand}${avatar}  __${
179-
commit.author
180-
}__, ${commit.fromNow()}   _(${commit.formatDate(dateFormat)})_ ${message}${commandBar}`
101+
CommitFormatter.fromTemplate(Container.config.hovers.detailsMarkdownFormat, commit, {
102+
annotationType: annotationType,
103+
dateFormat: dateFormat,
104+
line: line,
105+
markdown: true,
106+
remotes: remotes
107+
})
181108
);
182109
markdown.isTrusted = true;
183110
return markdown;

0 commit comments

Comments
 (0)