Skip to content

Commit 536cae0

Browse files
committed
Adds avatars to gutter and hover blame annotations
1 parent abf60c2 commit 536cae0

17 files changed

+163
-103
lines changed

CHANGELOG.md

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

77
## [7.3.0-beta4] - 2018-01-11
88
### Added
9+
- Adds [Gravatar](https://en.gravatar.com/) support to gutter and hover blame annotations
10+
- Adds `gitlens.annotations.file.gutter.gravatars` setting to specify whether or not to show gravatar images in the gutter blame annotations
911
- Adds support for providing blame annotations, code lens, etc on files with unsaved changes -- closes [#112](https://github.com/eamodio/vscode-gitlens/issues/112)
1012
- Adds `gitlens.defaultDateStyle` setting to specify how dates will be displayed by default -- closes [#89](https://github.com/eamodio/vscode-gitlens/issues/89)
1113
- Adds *Compare with Working* command (`gitlens.explorers.compareWithWorking`) to branch, tag, and revision (commit) nodes in the **GitLens** view to compare the current selection with the current working tree in the **GitLens Results** view
@@ -26,6 +28,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
2628
- Renames *Open Changes with Working Tree* command (`gitlens.openChangesWithWorking`) to *Open Changes with Working File*
2729
- Renames *Compare Selected Ancestor with Working* command (`gitlens.compareSelectedAncestorWithWorking`) to *Compare Selected Ancestor with Working Tree*
2830
- Renames *Compare with Working* command (`gitlens.compareWithWorking`) to *Compare with Working Tree*
31+
- Deprecates `gitlens.gitExplorer.gravatarsDefault` setting, replaced by `gitlens.defaultGravatarsStyle`
32+
- Deprecates `gitlens.resultsExplorer.gravatarsDefault` setting, replaced by `gitlens.defaultGravatarsStyle`
2933

3034
### Fixed
3135
- Fixes issue where the **GitLens Results** view wouldn't properly update when replacing existing results

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ GitLens is highly customizable and provides many configuration settings to allow
387387
|-----|------------
388388
|`gitlens.defaultDateFormat`|Specifies how absolute dates will be formatted by default<br />See https://momentjs.com/docs/#/displaying/format/ for valid formats
389389
|`gitlens.defaultDateStyle`|Specifies how dates will be displayed by default
390+
|`gitlens.defaultGravatarsStyle`|Specifies the style of the gravatar default (fallback) images<br />`identicon` - a geometric pattern<br />`mm` - (mystery-man) a simple, cartoon-style silhouetted outline of a person (does not vary by email hash)<br />`monsterid` - a monster with different colors, faces, etc<br />`retro` - 8-bit arcade-style pixelated faces<br />`robohash` - a robot with different colors, faces, etc<br />`wavatar` - faces with differing features and backgrounds
390391
|`gitlens.insiders`|Opts into the insiders channel -- provides access to upcoming features
391392
|`gitlens.keymap`|Specifies the keymap to use for GitLens shortcut keys<br />`standard` - adds a standard set of shortcut keys<br />`chorded` - adds a chorded set of shortcut keys that all start with `Ctrl+Alt+G` (`⌥⌘G` on macOS)<br />`none` - no shortcut keys will be added
392393
|`gitlens.outputLevel`|Specifies how much (if any) output will be sent to the GitLens output channel
@@ -407,6 +408,7 @@ GitLens is highly customizable and provides many configuration settings to allow
407408
|`gitlens.annotations.file.gutter.format`|Specifies the format of the gutter blame annotations<br />Available tokens<br />`${id}` - commit id<br />`${author}` - commit author<br />`${message}` - commit message<br />`${ago}` - relative commit date (e.g. 1 day ago)<br />`${date}` - formatted commit date (format specified by `gitlens.annotations.file.gutter.dateFormat`)<br />`${authorAgo}` - commit author, relative commit date<br />See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting
408409
|`gitlens.annotations.file.gutter.dateFormat`|Specifies how to format absolute dates (using the `${date}` token) in gutter blame annotations<br />See https://momentjs.com/docs/#/displaying/format/ for valid formats
409410
|`gitlens.annotations.file.gutter.compact`|Specifies whether or not to compact (deduplicate) matching adjacent gutter blame annotations
411+
|`gitlens.annotations.file.gutter.gravatars`|Specifies whether or not to show gravatar images in the gutter blame annotations
410412
|`gitlens.annotations.file.gutter.heatmap.enabled`|Specifies whether or not to provide a heatmap indicator in the gutter blame annotations
411413
|`gitlens.annotations.file.gutter.heatmap.location`|Specifies where the heatmap indicators will be shown in the gutter blame annotations<br />`left` - adds a heatmap indicator on the left edge of the gutter blame annotations<br />`right` - adds a heatmap indicator on the right edge of the gutter blame annotations
412414
|`gitlens.annotations.file.gutter.hover.details`|Specifies whether or not to provide a commit details hover annotation over the gutter blame annotations
@@ -465,7 +467,6 @@ GitLens is highly customizable and provides many configuration settings to allow
465467
|`gitlens.gitExplorer.commitFormat`|Specifies the format of committed changes in the **GitLens** view<br />Available tokens<br /> ${id} - commit id<br /> ${author} - commit author<br /> ${message} - commit message<br /> ${ago} - relative commit date (e.g. 1 day ago)<br /> ${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br /> ${authorAgo} - commit author, relative commit date<br />See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting
466468
|`gitlens.gitExplorer.commitFileFormat`|Specifies the format of a committed file in the **GitLens** view<br />Available tokens<br /> ${directory} - directory name<br /> ${file} - file name<br /> ${filePath} - formatted file name and path<br /> ${path} - full file path
467469
|`gitlens.gitExplorer.gravatars`|Specifies whether or not to show gravatar images instead of commit (or status) icons in the **GitLens** view
468-
|`gitlens.gitExplorer.gravatarsDefault`|Specifies the style of the gravatar default (fallback) images in the **GitLens** view<br />`identicon` - a geometric pattern<br />`mm` - (mystery-man) a simple, cartoon-style silhouetted outline of a person (does not vary by email hash)<br />`monsterid` - a monster with different colors, faces, etc<br />`retro` - 8-bit arcade-style pixelated faces<br />`robohash` - a robot with different colors, faces, etc<br />`wavatar` - faces with differing features and backgrounds
469470
|`gitlens.gitExplorer.includeWorkingTree`|Specifies whether or not to include working tree files inside the `Repository Status` node of the **GitLens** view
470471
|`gitlens.gitExplorer.showTrackingBranch`|Specifies whether or not to show the tracking branch when displaying local branches in the **GitLens** view"
471472
|`gitlens.gitExplorer.stashFormat`|Specifies the format of stashed changes in the **GitLens** view<br />Available tokens<br /> ${id} - commit id<br /> ${author} - commit author<br /> ${message} - commit message<br /> ${ago} - relative commit date (e.g. 1 day ago)<br /> ${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br /> ${authorAgo} - commit author, relative commit date<br />See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting
@@ -482,7 +483,6 @@ GitLens is highly customizable and provides many configuration settings to allow
482483
|`gitlens.resultsExplorer.commitFormat`|Specifies the format of committed changes in the **GitLens Results** view<br />Available tokens<br /> ${id} - commit id<br /> ${author} - commit author<br /> ${message} - commit message<br /> ${ago} - relative commit date (e.g. 1 day ago)<br /> ${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br /> ${authorAgo} - commit author, relative commit date<br />See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting
483484
|`gitlens.resultsExplorer.commitFileFormat`|Specifies the format of a committed file in the **GitLens Results** view<br />Available tokens<br /> ${directory} - directory name<br /> ${file} - file name<br /> ${filePath} - formatted file name and path<br /> ${path} - full file path
484485
|`gitlens.resultsExplorer.gravatars`|Specifies whether or not to show gravatar images instead of commit (or status) icons in the **GitLens Results** view
485-
|`gitlens.resultsExplorer.gravatarsDefault`|Specifies the style of the gravatar default (fallback) images in the **GitLens Results** view<br />`identicon` - a geometric pattern<br />`mm` - (mystery-man) a simple, cartoon-style silhouetted outline of a person (does not vary by email hash)<br />`monsterid` - a monster with different colors, faces, etc<br />`retro` - 8-bit arcade-style pixelated faces<br />`robohash` - a robot with different colors, faces, etc<br />`wavatar` - faces with differing features and backgrounds
486486
|`gitlens.resultsExplorer.showTrackingBranch`|Specifies whether or not to show the tracking branch when displaying local branches in the **GitLens Results** view"
487487
|`gitlens.resultsExplorer.stashFormat`|Specifies the format of stashed changes in the **GitLens Results** view<br />Available tokens<br /> ${id} - commit id<br /> ${author} - commit author<br /> ${message} - commit message<br /> ${ago} - relative commit date (e.g. 1 day ago)<br /> ${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br /> ${authorAgo} - commit author, relative commit date<br />See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting
488488
|`gitlens.resultsExplorer.stashFileFormat`|Specifies the format of a stashed file in the **GitLens Results** view<br />Available tokens<br /> ${directory} - directory name<br /> ${file} - file name<br /> ${filePath} - formatted file name and path<br /> ${path} - full file path
@@ -516,10 +516,10 @@ GitLens is highly customizable and provides many configuration settings to allow
516516

517517
|Name | Description
518518
|-----|------------
519-
|`gitlens.advanced.git`|Specifies the git path to use
520519
|`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
521520
|`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
522521
|`gitlens.advanced.caching.enabled`|Specifies whether git output will be cached -- changing the default is not recommended
522+
|`gitlens.advanced.git`|Specifies the git path to use
523523
|`gitlens.advanced.maxListItems`|Specifies the maximum number of items to show in a list. Use 0 to specify no maximum
524524
|`gitlens.advanced.menus`|Specifies which commands will be added to which menus
525525
|`gitlens.advanced.messages`|Specifies which messages should be suppressed

package.json

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@
102102
"description": "Specifies whether or not to compact (deduplicate) matching adjacent gutter blame annotations",
103103
"scope": "window"
104104
},
105+
"gitlens.annotations.file.gutter.gravatars": {
106+
"type": "boolean",
107+
"default": true,
108+
"description": "Specifies whether or not to show gravatar images in the gutter blame annotations",
109+
"scope": "window"
110+
},
105111
"gitlens.annotations.file.gutter.heatmap.enabled": {
106112
"type": "boolean",
107113
"default": true,
@@ -488,6 +494,20 @@
488494
"description": "Specifies how dates will be displayed by default",
489495
"scope": "window"
490496
},
497+
"gitlens.defaultGravatarsStyle": {
498+
"type": "string",
499+
"default": "robohash",
500+
"enum": [
501+
"identicon",
502+
"mm",
503+
"monsterid",
504+
"retro",
505+
"robohash",
506+
"wavatar"
507+
],
508+
"description": "Specifies the style of the gravatar default (fallback) images\n `identicon` - a geometric pattern\n `mm` - (mystery-man) a simple, cartoon-style silhouetted outline of a person (does not vary by email hash)\n `monsterid` - a monster with different colors, faces, etc\n `retro` - 8-bit arcade-style pixelated faces\n `robohash` - a robot with different colors, faces, etc\n `wavatar` - faces with differing features and backgrounds",
509+
"scope": "window"
510+
},
491511
"gitlens.gitExplorer.autoRefresh": {
492512
"type": "boolean",
493513
"default": true,
@@ -541,20 +561,6 @@
541561
"description": "Specifies whether or not to show gravatar images instead of commit (or status) icons in the `GitLens` view",
542562
"scope": "window"
543563
},
544-
"gitlens.gitExplorer.gravatarsDefault": {
545-
"type": "string",
546-
"default": "robohash",
547-
"enum": [
548-
"identicon",
549-
"mm",
550-
"monsterid",
551-
"retro",
552-
"robohash",
553-
"wavatar"
554-
],
555-
"description": "Specifies the style of the gravatar default (fallback) images in the `GitLens` view\n `identicon` - a geometric pattern\n `mm` - (mystery-man) a simple, cartoon-style silhouetted outline of a person (does not vary by email hash)\n `monsterid` - a monster with different colors, faces, etc\n `retro` - 8-bit arcade-style pixelated faces\n `robohash` - a robot with different colors, faces, etc\n `wavatar` - faces with differing features and backgrounds",
556-
"scope": "window"
557-
},
558564
"gitlens.gitExplorer.includeWorkingTree": {
559565
"type": "boolean",
560566
"default": true,
@@ -730,20 +736,6 @@
730736
"description": "Specifies whether or not to show gravatar images instead of commit (or status) icons in the `GitLens Results` view",
731737
"scope": "window"
732738
},
733-
"gitlens.resultsExplorer.gravatarsDefault": {
734-
"type": "string",
735-
"default": "robohash",
736-
"enum": [
737-
"identicon",
738-
"mm",
739-
"monsterid",
740-
"retro",
741-
"robohash",
742-
"wavatar"
743-
],
744-
"description": "Specifies the style of the gravatar default (fallback) images in the `GitLens Results` view\n `identicon` - a geometric pattern\n `mm` - (mystery-man) a simple, cartoon-style silhouetted outline of a person (does not vary by email hash)\n `monsterid` - a monster with different colors, faces, etc\n `retro` - 8-bit arcade-style pixelated faces\n `robohash` - a robot with different colors, faces, etc\n `wavatar` - faces with differing features and backgrounds",
745-
"scope": "window"
746-
},
747739
"gitlens.resultsExplorer.showTrackingBranch": {
748740
"type": "boolean",
749741
"default": true,

src/annotations/annotationProvider.ts

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,29 @@ export abstract class AnnotationProviderBase extends Disposable {
1717
public correlationKey: TextEditorCorrelationKey;
1818
public document: TextDocument;
1919

20-
protected _decorations: DecorationOptions[] | undefined;
21-
protected _disposable: Disposable;
20+
protected decorations: DecorationOptions[] | undefined;
21+
protected disposable: Disposable;
2222

2323
constructor(
2424
public editor: TextEditor,
2525
protected readonly trackedDocument: TrackedDocument<GitDocumentState>,
26-
protected _decoration: TextEditorDecorationType | undefined,
27-
protected _highlightDecoration: TextEditorDecorationType | undefined
26+
protected decoration: TextEditorDecorationType | undefined,
27+
protected highlightDecoration: TextEditorDecorationType | undefined
2828
) {
2929
super(() => this.dispose());
3030

3131
this.correlationKey = AnnotationProviderBase.getCorrelationKey(this.editor);
3232
this.document = this.editor.document;
3333

34-
this._disposable = Disposable.from(
34+
this.disposable = Disposable.from(
3535
window.onDidChangeTextEditorSelection(this.onTextEditorSelectionChanged, this)
3636
);
3737
}
3838

3939
async dispose() {
4040
await this.clear();
4141

42-
this._disposable && this._disposable.dispose();
42+
this.disposable && this.disposable.dispose();
4343
}
4444

4545
private async onTextEditorSelectionChanged(e: TextEditorSelectionChangeEvent) {
@@ -58,16 +58,32 @@ export abstract class AnnotationProviderBase extends Disposable {
5858
return this.editor.document.uri;
5959
}
6060

61+
protected decorationTypes: TextEditorDecorationType[] | undefined;
62+
6163
async clear() {
62-
if (this.editor !== undefined) {
64+
if (this.editor === undefined || this.decorationTypes === undefined || this.decorationTypes.length === 0) return;
65+
66+
if (this.decoration !== undefined) {
6367
try {
64-
if (this._highlightDecoration !== undefined) {
65-
this.editor.setDecorations(this._highlightDecoration, []);
66-
}
68+
this.editor.setDecorations(this.decoration, []);
69+
}
70+
catch { }
71+
}
6772

68-
if (this._decoration !== undefined) {
69-
this.editor.setDecorations(this._decoration, []);
73+
if (this.decorationTypes !== undefined && this.decorationTypes.length > 0) {
74+
for (const dt of this.decorationTypes) {
75+
try {
76+
this.editor.setDecorations(dt, []);
7077
}
78+
catch { }
79+
}
80+
81+
this.decorationTypes = undefined;
82+
}
83+
84+
if (this.highlightDecoration !== undefined) {
85+
try {
86+
this.editor.setDecorations(this.highlightDecoration, []);
7187
}
7288
catch { }
7389
}
@@ -87,8 +103,8 @@ export abstract class AnnotationProviderBase extends Disposable {
87103
if (changes !== undefined) {
88104
await this.clear();
89105

90-
this._decoration = changes.decoration;
91-
this._highlightDecoration = changes.highlightDecoration;
106+
this.decoration = changes.decoration;
107+
this.highlightDecoration = changes.highlightDecoration;
92108
}
93109

94110
await this.provideAnnotation(this.editor === undefined ? undefined : this.editor.selection.active.line);
@@ -103,8 +119,8 @@ export abstract class AnnotationProviderBase extends Disposable {
103119
this.correlationKey = AnnotationProviderBase.getCorrelationKey(editor);
104120
this.document = editor.document;
105121

106-
if (this._decorations !== undefined && this._decorations.length) {
107-
this.editor.setDecorations(this._decoration!, this._decorations);
122+
if (this.decorations !== undefined && this.decorations.length) {
123+
this.editor.setDecorations(this.decoration!, this.decorations);
108124
}
109125
}
110126

src/annotations/annotations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class Annotations {
8989
showCommitDetailsCommand = `\`${commit.shortSha}\``;
9090
}
9191

92-
const markdown = new MarkdownString(`${showCommitDetailsCommand} &nbsp; __${commit.author}__, ${commit.fromNow()} &nbsp; _(${commit.formatDate(dateFormat)})_ ${message}${commandBar}`);
92+
const markdown = new MarkdownString(`${showCommitDetailsCommand} &nbsp; ![](${commit.getGravatarUri(Container.config.defaultGravatarsStyle).toString()}) &nbsp;__${commit.author}__, ${commit.fromNow()} &nbsp; _(${commit.formatDate(dateFormat)})_ ${message}${commandBar}`);
9393
markdown.isTrusted = true;
9494
return markdown;
9595
}

0 commit comments

Comments
 (0)