Ver a proveniência

Adds customization for hovers + email link - closes #642

Adds author email to commit node tooltips
Adds ${email} token to many formats
main
Eric Amodio há 5 anos
ascendente
cometimento
6658285b46
7 ficheiros alterados com 190 adições e 146 eliminações
  1. +8
    -0
      CHANGELOG.md
  2. +54
    -53
      README.md
  3. +13
    -7
      package.json
  4. +7
    -80
      src/annotations/annotations.ts
  5. +106
    -5
      src/git/formatters/commitFormatter.ts
  6. +1
    -0
      src/ui/config.ts
  7. +1
    -1
      src/views/nodes/commitNode.ts

+ 8
- 0
CHANGELOG.md Ver ficheiro

@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased]
### Added
- Adds a `mailto:` link to the author on the _commit details_ hover — closes [#642](https://github.com/eamodio/vscode-gitlens/issues/642)
- Adds support for customizing the layout of the _commit details_ hover
- Adds a `gitlens.hovers.detailsMarkdownFormat` setting to specify the format (in markdown) of the _commit details_ hover
- Adds the author's e-mail to the tooltip of commits in the views — closes [#642](https://github.com/eamodio/vscode-gitlens/issues/642)
- 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)
### Changed
- Changes the sorting of remotes in the _Repositories_ view to sort the default remote first

+ 54
- 53
README.md Ver ficheiro

@ -649,43 +649,44 @@ GitLens is highly customizable and provides many configuration settings to allow
### Current Line Blame Settings [#](#current-line-blame-settings- 'Current Line Blame Settings')
| Name | Description |
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gitlens.currentLine.dateFormat` | Specifies how to format absolute dates (using the `${date}` token) for the current line blame annotations. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats |
| `gitlens.currentLine.enabled` | Specifies whether to provide a blame annotation for the current line, by default. Use the _Toggle Line Blame Annotations_ command (`gitlens.toggleLineBlame`) to toggle the annotations on and off for the current window |
| `gitlens.currentLine.format` | 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<br /><br />Available tokens<br />`${id}` &mdash; commit id<br />`${author}` &mdash; commit author<br />`${message}` &mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}` &mdash; formatted commit date (format specified by `gitlens.currentLine.dateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}` &mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; commit author, commit date specified by `gitlens.defaultDateStyle` |
| `gitlens.currentLine.scrollable` | Specifies whether the current line blame annotation can be scrolled into view when it is outside the viewport |
| Name | Description |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `gitlens.currentLine.dateFormat` | Specifies how to format absolute dates (using the `${date}` token) for the current line blame annotations. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats |
| `gitlens.currentLine.enabled` | Specifies whether to provide a blame annotation for the current line, by default. Use the _Toggle Line Blame Annotations_ command (`gitlens.toggleLineBlame`) to toggle the annotations on and off for the current window |
| `gitlens.currentLine.format` | 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<br /><br />Available tokens<br />`${id}` &mdash; commit id<br />`${author}` &mdash; commit author<br />`${email}` &mdash; commit author e-mail<br />`${message}` &mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}` &mdash; formatted commit date (format specified by `gitlens.currentLine.dateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}` &mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; commit author, commit date specified by `gitlens.defaultDateStyle` |
| `gitlens.currentLine.scrollable` | Specifies whether the current line blame annotation can be scrolled into view when it is outside the viewport |
### Gutter Blame Settings [#](#gutter-blame-settings- 'Gutter Blame Settings')
| Name | Description |
| ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gitlens.blame.avatars` | Specifies whether to show avatar images in the gutter blame annotations |
| `gitlens.blame.compact` | Specifies whether to compact (deduplicate) matching adjacent gutter blame annotations |
| `gitlens.blame.dateFormat` | Specifies how to format absolute dates (using the `${date}` token) in gutter blame annotations. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats |
| `gitlens.blame.format` | Specifies the format of the gutter blame annotations. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting<br /><br />Available tokens<br />`${id}` &mdash; commit id<br />`${author}` &mdash; commit author<br />`${message}` &mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}` &mdash; formatted commit date (format specified by `gitlens.blame.dateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}` &mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; commit author, commit date specified by `gitlens.defaultDateStyle` |
| `gitlens.blame.heatmap.enabled` | Specifies whether to provide a heatmap indicator in the gutter blame annotations |
| `gitlens.blame.heatmap.location` | Specifies where the heatmap indicators will be shown in the gutter blame annotations<br /><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 |
| `gitlens.blame.highlight.enabled` | Specifies whether to highlight lines associated with the current line |
| `gitlens.blame.highlight.locations` | Specifies where the associated line highlights will be shown<br /><br />`gutter` - adds a gutter glyph<br />`line` - adds a full-line highlight background color<br />`overview` - adds a decoration to the overview ruler (scroll bar) |
| `gitlens.blame.ignoreWhitespace` | Specifies whether to ignore whitespace when comparing revisions during blame operations |
| `gitlens.blame.separateLines` | Specifies whether gutter blame annotations will have line separators |
| `gitlens.blame.toggleMode` | Specifies how the gutter blame annotations will be toggled<br /><br />`file` - toggles each file individually<br />`window` - toggles the window, i.e. all files at once |
| Name | Description |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gitlens.blame.avatars` | Specifies whether to show avatar images in the gutter blame annotations |
| `gitlens.blame.compact` | Specifies whether to compact (deduplicate) matching adjacent gutter blame annotations |
| `gitlens.blame.dateFormat` | Specifies how to format absolute dates (using the `${date}` token) in gutter blame annotations. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats |
| `gitlens.blame.format` | Specifies the format of the gutter blame annotations. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting<br /><br />Available tokens<br />`${id}` &mdash; commit id<br />`${author}` &mdash; commit author<br />`${email}` &mdash; commit author e-mail<br />`${message}` &mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}` &mdash; formatted commit date (format specified by `gitlens.blame.dateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}` &mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; commit author, commit date specified by `gitlens.defaultDateStyle` |
| `gitlens.blame.heatmap.enabled` | Specifies whether to provide a heatmap indicator in the gutter blame annotations |
| `gitlens.blame.heatmap.location` | Specifies where the heatmap indicators will be shown in the gutter blame annotations<br /><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 |
| `gitlens.blame.highlight.enabled` | Specifies whether to highlight lines associated with the current line |
| `gitlens.blame.highlight.locations` | Specifies where the associated line highlights will be shown<br /><br />`gutter` - adds a gutter glyph<br />`line` - adds a full-line highlight background color<br />`overview` - adds a decoration to the overview ruler (scroll bar) |
| `gitlens.blame.ignoreWhitespace` | Specifies whether to ignore whitespace when comparing revisions during blame operations |
| `gitlens.blame.separateLines` | Specifies whether gutter blame annotations will have line separators |
| `gitlens.blame.toggleMode` | Specifies how the gutter blame annotations will be toggled<br /><br />`file` - toggles each file individually<br />`window` - toggles the window, i.e. all files at once |
### Hover Settings [#](#hover-settings- 'Hover Settings')
| Name | Description |
| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gitlens.hovers.annotations.changes` | Specifies whether to provide a _changes (diff)_ hover for all lines when showing blame annotations |
| `gitlens.hovers.annotations.details` | Specifies whether to provide a _commit details_ hover for all lines when showing blame annotations |
| `gitlens.hovers.annotations.enabled` | Specifies whether to provide any hovers when showing blame annotations |
| `gitlens.hovers.annotations.over` | Specifies when to trigger hovers when showing blame annotations<br /><br />`annotation` - only shown when hovering over the line annotation<br />`line` - shown when hovering anywhere over the line |
| `gitlens.hovers.avatars` | Specifies whether to show avatar images in hovers |
| `gitlens.hovers.currentLine.changes` | Specifies whether to provide a _changes (diff)_ hover for the current line |
| `gitlens.hovers.currentLine.details` | Specifies whether to provide a _commit details_ hover for the current line |
| `gitlens.hovers.currentLine.enabled` | Specifies whether to provide any hovers for the current line |
| `gitlens.hovers.currentLine.over` | Specifies when to trigger hovers for the current line<br /><br />`annotation` - only shown when hovering over the line annotation<br />`line` - shown when hovering anywhere over the line |
| `gitlens.hovers.enabled` | Specifies whether to provide any hovers |
| Name | Description |
| -------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gitlens.hovers.annotations.changes` | Specifies whether to provide a _changes (diff)_ hover for all lines when showing blame annotations |
| `gitlens.hovers.annotations.details` | Specifies whether to provide a _commit details_ hover for all lines when showing blame annotations |
| `gitlens.hovers.annotations.enabled` | Specifies whether to provide any hovers when showing blame annotations |
| `gitlens.hovers.annotations.over` | Specifies when to trigger hovers when showing blame annotations<br /><br />`annotation` - only shown when hovering over the line annotation<br />`line` - shown when hovering anywhere over the line |
| `gitlens.hovers.avatars` | Specifies whether to show avatar images in hovers |
| `gitlens.hovers.currentLine.changes` | Specifies whether to provide a _changes (diff)_ hover for the current line |
| `gitlens.hovers.currentLine.details` | Specifies whether to provide a _commit details_ hover for the current line |
| `gitlens.hovers.currentLine.enabled` | Specifies whether to provide any hovers for the current line |
| `gitlens.hovers.currentLine.over` | Specifies when to trigger hovers for the current line<br /><br />`annotation` - only shown when hovering over the line annotation<br />`line` - shown when hovering anywhere over the line |
| `gitlens.hovers.enabled` | Specifies whether to provide any hovers |
| `gitlens.hovers.detailsMarkdownFormat` | Specifies the (in markdown) of the _commit details_ hover. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting<br /><br />Available tokens<br />`${id}` &mdash; commit id<br />`${author}` &mdash; commit author<br />`${email}` &mdash; commit author e-mail<br />`${message}` &mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}` &mdash; formatted commit date (format specified by `gitlens.defaultDateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}` &mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; commit author, commit date specified by `gitlens.defaultDateStyle`<br />`${avatar}` &mdash; commit author avatar<br />`${commands}` &mdash; a set of commit commands |
### Code Lens Settings [#](#code-lens-settings- 'Code Lens Settings')
@ -719,14 +720,14 @@ GitLens is highly customizable and provides many configuration settings to allow
### Status Bar Settings [#](#status-bar-settings- 'Status Bar Settings')
| Name | Description |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gitlens.statusBar.alignment` | Specifies the blame alignment in the status bar<br /><br />`left` - aligns to the left<br />`right` - aligns to the right |
| `gitlens.statusBar.command` | Specifies the command to be executed when the blame status bar item is clicked<br /><br />`gitlens.toggleFileBlame` - toggles file blame annotations<br />`gitlens.diffWithPrevious` - compares the current line commit with the previous<br />`gitlens.diffWithWorking` - compares the current line commit with the working tree<br />`gitlens.toggleCodeLens` - toggles Git code lens<br />`gitlens.showQuickCommitDetails` - shows a commit details quick pick<br />`gitlens.showQuickCommitFileDetails` - shows a commit file details quick pick<br />`gitlens.showQuickFileHistory` - shows a file history quick pick<br />`gitlens.showQuickRepoHistory` - shows a branch history quick pick |
| `gitlens.statusBar.dateFormat` | Specifies the date format of absolute dates shown in the blame information in the status bar. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats |
| `gitlens.statusBar.enabled` | Specifies whether to provide blame information in the status bar |
| `gitlens.statusBar.format` | Specifies the format of the blame information in the status bar. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting<br /><br />Available tokens<br />`${id}` &mdash; commit id<br />`${author}` &mdash; commit author<br />`${message}` &mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}` &mdash; formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}` &mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; commit author, commit date specified by `gitlens.defaultDateStyle` |
| `gitlens.statusBar.reduceFlicker` | Specifies whether to avoid clearing the previous blame information when changing lines to reduce status bar "flashing" |
| Name | Description |
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gitlens.statusBar.alignment` | Specifies the blame alignment in the status bar<br /><br />`left` - aligns to the left<br />`right` - aligns to the right |
| `gitlens.statusBar.command` | Specifies the command to be executed when the blame status bar item is clicked<br /><br />`gitlens.toggleFileBlame` - toggles file blame annotations<br />`gitlens.diffWithPrevious` - compares the current line commit with the previous<br />`gitlens.diffWithWorking` - compares the current line commit with the working tree<br />`gitlens.toggleCodeLens` - toggles Git code lens<br />`gitlens.showQuickCommitDetails` - shows a commit details quick pick<br />`gitlens.showQuickCommitFileDetails` - shows a commit file details quick pick<br />`gitlens.showQuickFileHistory` - shows a file history quick pick<br />`gitlens.showQuickRepoHistory` - shows a branch history quick pick |
| `gitlens.statusBar.dateFormat` | Specifies the date format of absolute dates shown in the blame information in the status bar. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats |
| `gitlens.statusBar.enabled` | Specifies whether to provide blame information in the status bar |
| `gitlens.statusBar.format` | Specifies the format of the blame information in the status bar. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting<br /><br />Available tokens<br />`${id}` &mdash; commit id<br />`${author}` &mdash; commit author<br />`${email}` &mdash; commit author e-mail<br />`${message}` &mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}` &mdash; formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}` &mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; commit author, commit date specified by `gitlens.defaultDateStyle` |
| `gitlens.statusBar.reduceFlicker` | Specifies whether to avoid clearing the previous blame information when changing lines to reduce status bar "flashing" |
### Repositories View Settings [#](#repositories-view-settings- 'Repositories View Settings')
@ -795,20 +796,20 @@ See also [View Settings](#view-settings- 'Jump to the View settings')
### View Settings [#](#view-settings- 'View Settings')
| Name | Description |
| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gitlens.views.commitFileFormat` | Specifies the format of a committed file in the views<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; full file path |
| `gitlens.views.commitFileDescriptionFormat` | Specifies the description format of a committed file in the views<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; full file path |
| `gitlens.views.commitFormat` | 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<br /><br />Available tokens<br />`${id}`&mdash; commit id<br />`${author}` &mdash; commit author<br />`${message}`&mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}`&mdash; formatted commit date (format specified by`gitlens.statusBar.dateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}`&mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; commit author, commit date specified by `gitlens.defaultDateStyle` |
| `gitlens.views.commitDescriptionFormat` | 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<br /><br />Available tokens<br />`${id}`&mdash; commit id<br />`${author}` &mdash; commit author<br />`${message}`&mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}`&mdash; formatted commit date (format specified by`gitlens.statusBar.dateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}`&mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; commit author, commit date specified by `gitlens.defaultDateStyle` |
| `gitlens.views.defaultItemLimit` | Specifies the default number of items to show in a view list. Use 0 to specify no limit |
| `gitlens.views.showRelativeDateMarkers` | Specifies whether to show relative date markers (_Less than a week ago_, _Over a week ago_, _Over a month ago_, etc) on revision (commit) histories in the views |
| `gitlens.views.stashFileFormat` | Specifies the format of a stashed file in the views<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; full file path |
| `gitlens.views.stashFileDescriptionFormat` | Specifies the description format of a stashed file in the views<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; full file path |
| `gitlens.views.stashFormat` | 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<br /><br />Available tokens<br />`${id}` &mdash; commit id<br />`${author}` &mdash; commit author<br />`${message}` &mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}`&mdash; formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}` &mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; commit author, commit date specified by `gitlens.defaultDateStyle` |
| `gitlens.views.stashDescriptionFormat` | 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<br /><br />Available tokens<br />`${id}` &mdash; commit id<br />`${author}` &mdash; commit author<br />`${message}` &mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}`&mdash; formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}` &mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; commit author, commit date specified by `gitlens.defaultDateStyle` |
| `gitlens.views.statusFileFormat` | Specifies the format of the status of a working or committed file in the views<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; full file path<br />`${working}` &mdash; optional indicator if the file is uncommitted |
| `gitlens.views.statusFileDescriptionFormat` | Specifies the description format of the status of a working or committed file in the views<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; full file path<br />`${working}` &mdash; optional indicator if the file is uncommitted |
| Name | Description |
| ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `gitlens.views.commitFileFormat` | Specifies the format of a committed file in the views<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; full file path |
| `gitlens.views.commitFileDescriptionFormat` | Specifies the description format of a committed file in the views<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; full file path |
| `gitlens.views.commitFormat` | 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<br /><br />Available tokens<br />`${id}` &mdash; commit id<br />`${author}` &mdash; commit author<br />`${email}` &mdash; commit author e-mail<br />`${message}` &mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}` &mdash; formatted commit date (format specified by `gitlens.defaultDateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}` &mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; commit author, commit date specified by `gitlens.defaultDateStyle` |
| `gitlens.views.commitDescriptionFormat` | 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<br /><br />Available tokens<br />`${id}` &mdash; commit id<br />`${author}` &mdash; commit author<br />`${email}` &mdash; commit author e-mail<br />`${message}` &mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}` &mdash; formatted commit date (format specified by `gitlens.defaultDateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}` &mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; commit author, commit date specified by `gitlens.defaultDateStyle` |
| `gitlens.views.defaultItemLimit` | Specifies the default number of items to show in a view list. Use 0 to specify no limit |
| `gitlens.views.showRelativeDateMarkers` | Specifies whether to show relative date markers (_Less than a week ago_, _Over a week ago_, _Over a month ago_, etc) on revision (commit) histories in the views |
| `gitlens.views.stashFileFormat` | Specifies the format of a stashed file in the views<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; full file path |
| `gitlens.views.stashFileDescriptionFormat` | Specifies the description format of a stashed file in the views<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; full file path |
| `gitlens.views.stashFormat` | 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<br /><br />Available tokens<br />`${id}` &mdash; commit id<br />`${author}` &mdash; commit author<br />`${email}` &mdash; commit author e-mail<br />`${message}` &mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}` &mdash; formatted commit date (format specified by `gitlens.defaultDateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}` &mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; commit author, commit date specified by `gitlens.defaultDateStyle` |
| `gitlens.views.stashDescriptionFormat` | 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<br /><br />Available tokens<br />`${id}` &mdash; commit id<br />`${author}` &mdash; commit author<br />`${email}` &mdash; commit author e-mail<br />`${message}` &mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}` &mdash; formatted commit date (format specified by `gitlens.defaultDateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}` &mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; commit author, commit date specified by `gitlens.defaultDateStyle` |
| `gitlens.views.statusFileFormat` | Specifies the format of the status of a working or committed file in the views<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; full file path<br />`${working}` &mdash; optional indicator if the file is uncommitted |
| `gitlens.views.statusFileDescriptionFormat` | Specifies the description format of the status of a working or committed file in the views<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; full file path<br />`${working}` &mdash; optional indicator if the file is uncommitted |
### Modes Settings [#](#modes-settings- 'Modes Settings')

+ 13
- 7
package.json Ver ficheiro

@ -74,7 +74,7 @@
"gitlens.blame.format": {
"type": "string",
"default": "${message|40?} ${agoOrDate|14-}",
"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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.blame.dateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; commit author, commit date specified by `#gitlens.defaultDateStyle#`",
"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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${email}` &mdash; commit author e-mail\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.blame.dateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; commit author, commit date specified by `#gitlens.defaultDateStyle#`",
"scope": "window"
},
"gitlens.blame.heatmap.enabled": {
@ -398,7 +398,7 @@
"gitlens.currentLine.format": {
"type": "string",
"default": "${authorAgoOrDate} • ${message}",
"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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.currentLine.dateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; commit author, commit date specified by `#gitlens.defaultDateStyle#`",
"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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${email}` &mdash; commit author e-mail\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.currentLine.dateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; commit author, commit date specified by `#gitlens.defaultDateStyle#`",
"scope": "window"
},
"gitlens.currentLine.scrollable": {
@ -563,6 +563,12 @@
"markdownDescription": "Specifies whether to show avatar images in hovers",
"scope": "window"
},
"gitlens.hovers.detailsMarkdownFormat": {
"type": "string",
"default": "[${avatar} &nbsp;__${author}__](mailto:${email}), ${ago} &nbsp; _(${date})_ ${message}\n\n${commands}",
"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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${email}` &mdash; commit author e-mail\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; commit author, commit date specified by `#gitlens.defaultDateStyle#`\n - `${avatar}` &mdash; commit author avatar\n - `${commands}` &mdash; a set of commit commands",
"scope": "window"
},
"gitlens.hovers.enabled": {
"type": "boolean",
"default": true,
@ -1216,7 +1222,7 @@
"gitlens.statusBar.format": {
"type": "string",
"default": "${authorAgoOrDate}",
"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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.statusBar.dateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; commit author, commit date specified by `#gitlens.defaultDateStyle#`",
"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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${email}` &mdash; commit author e-mail\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.statusBar.dateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; commit author, commit date specified by `#gitlens.defaultDateStyle#`",
"scope": "window"
},
"gitlens.statusBar.reduceFlicker": {
@ -1258,13 +1264,13 @@
"gitlens.views.commitFormat": {
"type": "string",
"default": "${message}",
"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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; commit author, commit date specified by `#gitlens.defaultDateStyle#`",
"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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${email}` &mdash; commit author e-mail\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; commit author, commit date specified by `#gitlens.defaultDateStyle#`",
"scope": "window"
},
"gitlens.views.commitDescriptionFormat": {
"type": "string",
"default": "${changes • }${authorAgoOrDate}",
"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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; commit author, commit date specified by `#gitlens.defaultDateStyle#`",
"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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${email}` &mdash; commit author e-mail\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; commit author, commit date specified by `#gitlens.defaultDateStyle#`",
"scope": "window"
},
"gitlens.views.compare.avatars": {
@ -1562,13 +1568,13 @@
"gitlens.views.stashFormat": {
"type": "string",
"default": "${message}",
"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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.statusBar.dateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; commit author, commit date specified by `#gitlens.defaultDateStyle#`",
"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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${email}` &mdash; commit author e-mail\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; commit author, commit date specified by `#gitlens.defaultDateStyle#`",
"scope": "window"
},
"gitlens.views.stashDescriptionFormat": {
"type": "string",
"default": "${changes • }${agoOrDate}",
"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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.statusBar.dateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; commit author, commit date specified by `#gitlens.defaultDateStyle#`",
"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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${email}` &mdash; commit author e-mail\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; commit author, commit date specified by `#gitlens.defaultDateStyle#`",
"scope": "window"
},
"gitlens.views.statusFileFormat": {

+ 7
- 80
src/annotations/annotations.ts Ver ficheiro

@ -86,42 +86,6 @@ export class Annotations {
return `rgba(${computedHeatmapColor.rgb}, ${(1 - age / 10).toFixed(2)})`;
}
private static getHoverCommandBar(
commit: GitCommit,
hasRemote: boolean,
annotationType?: FileAnnotationType,
line: number = 0
) {
let commandBar = `[\`${GlyphChars.MuchGreaterThan}\`](${DiffWithCommand.getMarkdownCommandArgs(
commit
)} "Open Changes") `;
if (commit.previousSha !== undefined) {
if (annotationType === FileAnnotationType.RecentChanges) {
annotationType = FileAnnotationType.Blame;
}
const uri = GitUri.toRevisionUri(commit.previousSha, commit.previousUri.fsPath, commit.repoPath);
commandBar += `[\`${GlyphChars.SquareWithTopShadow}\`](${OpenFileRevisionCommand.getMarkdownCommandArgs(
uri,
annotationType || FileAnnotationType.Blame,
line
)} "Blame Previous Revision") `;
}
if (hasRemote) {
commandBar += `[\`${GlyphChars.ArrowUpRight}\`](${OpenCommitInRemoteCommand.getMarkdownCommandArgs(
commit.sha
)} "Open in Remote") `;
}
commandBar += `[\`${GlyphChars.MiddleEllipsis}\`](${ShowQuickCommitFileDetailsCommand.getMarkdownCommandArgs(
commit.sha
)} "Show More Actions")`;
return commandBar;
}
static getHoverMessage(
commit: GitCommit,
dateFormat: string | null,
@ -133,51 +97,14 @@ export class Annotations {
dateFormat = 'MMMM Do, YYYY h:mma';
}
let message = '';
let commandBar = '';
let showCommitDetailsCommand = '';
let avatar = '';
if (!commit.isUncommitted) {
commandBar = `\n\n${this.getHoverCommandBar(commit, remotes.length !== 0, annotationType, line)}`;
showCommitDetailsCommand = `[\`${commit.shortSha}\`](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(
commit.sha
)} "Show Commit Details")`;
message = CommitFormatter.fromTemplate('${message}', commit);
remotes.sort(
(a, b) =>
(a.default ? -1 : 1) - (b.default ? -1 : 1) ||
a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' })
);
for (const r of remotes) {
if (r.provider === undefined) continue;
message = r.provider.enrichMessage(message);
break;
}
message = `\n\n> ${message
// Escape markdown
.replace(escapeMarkdownRegex, '\\$&')
// Escape markdown header (since the above regex won't match it)
.replace(/^===/gm, markdownHeaderReplacement)
// Keep under the same block-quote but with line breaks
.replace(/\n/g, '\t\n> ')}`;
}
else {
showCommitDetailsCommand = `\`${commit.shortSha === 'Working Tree' ? '00000000' : commit.shortSha}\``;
}
if (Container.config.hovers.avatars) {
avatar = ` &nbsp; ![](${commit.getGravatarUri(Container.config.defaultGravatarsStyle).toString(true)})`;
}
const markdown = new MarkdownString(
`${showCommitDetailsCommand}${avatar} &nbsp;__${
commit.author
}__, ${commit.fromNow()} &nbsp; _(${commit.formatDate(dateFormat)})_ ${message}${commandBar}`
CommitFormatter.fromTemplate(Container.config.hovers.detailsMarkdownFormat, commit, {
annotationType: annotationType,
dateFormat: dateFormat,
line: line,
markdown: true,
remotes: remotes
})
);
markdown.isTrusted = true;
return markdown;

+ 106
- 5
src/git/formatters/commitFormatter.ts Ver ficheiro

@ -1,17 +1,33 @@
'use strict';
import { DateStyle } from '../../configuration';
import {
DiffWithCommand,
OpenCommitInRemoteCommand,
OpenFileRevisionCommand,
ShowQuickCommitDetailsCommand,
ShowQuickCommitFileDetailsCommand
} from '../../commands';
import { DateStyle, FileAnnotationType } from '../../configuration';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { Strings } from '../../system';
import { GitUri } from '../gitUri';
import { GitCommit, GitCommitType } from '../models/commit';
import { GitLogCommit } from '../models/models';
import { GitLogCommit, GitRemote } from '../models/models';
import { Formatter, IFormatOptions } from './formatter';
const emojiMap: { [key: string]: string } = require('../../../emoji/emojis.json');
const emojiRegex = /:([-+_a-z0-9]+):/g;
const escapeMarkdownRegex = /[`\>\#\*\_\-\+\.]/g;
// const sampleMarkdown = '## message `not code` *not important* _no underline_ \n> don\'t quote me \n- don\'t list me \n+ don\'t list me \n1. don\'t list me \nnot h1 \n=== \nnot h2 \n---\n***\n---\n___';
const markdownHeaderReplacement = `${GlyphChars.ZeroWidthSpace}===`;
export interface ICommitFormatOptions extends IFormatOptions {
annotationType?: FileAnnotationType;
dateStyle?: DateStyle;
line?: number;
markdown?: boolean;
remotes?: GitRemote[];
truncateMessageAtNewLine?: boolean;
tokenOptions?: {
@ -23,6 +39,7 @@ export interface ICommitFormatOptions extends IFormatOptions {
changes?: Strings.ITokenOptions;
changesShort?: Strings.ITokenOptions;
date?: Strings.ITokenOptions;
email?: Strings.ITokenOptions;
id?: Strings.ITokenOptions;
message?: Strings.ITokenOptions;
};
@ -52,8 +69,7 @@ export class CommitFormatter extends Formatter
}
get author() {
const author = this._item.author;
return this._padOrTruncate(author, this._options.tokenOptions!.author);
return this._padOrTruncate(this._item.author, this._options.tokenOptions!.author);
}
get authorAgo() {
@ -66,6 +82,14 @@ export class CommitFormatter extends Formatter
return this._padOrTruncate(authorAgo, this._options.tokenOptions!.authorAgoOrDate);
}
get avatar() {
if (!this._options.markdown || !Container.config.hovers.avatars) {
return '';
}
return `![](${this._item.getGravatarUri(Container.config.defaultGravatarsStyle).toString(true)})`;
}
get changes() {
if (!(this._item instanceof GitLogCommit) || this._item.type === GitCommitType.File) {
return this._padOrTruncate('', this._options.tokenOptions!.changes);
@ -85,10 +109,60 @@ export class CommitFormatter extends Formatter
);
}
get commands() {
if (this._item.isUncommitted) {
return `\`${
this._item.shortSha === 'Working Tree'
? this._padOrTruncate('00000000', this._options.tokenOptions!.id)
: this.id
}\``;
}
let commands = `[\`${this.id}\`](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(
this._item.sha
)} "Show Commit Details") [\`${GlyphChars.MuchGreaterThan}\`](${DiffWithCommand.getMarkdownCommandArgs(
this._item
)} "Open Changes") `;
if (this._item.previousSha !== undefined) {
let annotationType = this._options.annotationType;
if (annotationType === FileAnnotationType.RecentChanges) {
annotationType = FileAnnotationType.Blame;
}
const uri = GitUri.toRevisionUri(
this._item.previousSha,
this._item.previousUri.fsPath,
this._item.repoPath
);
commands += `[\`${GlyphChars.SquareWithTopShadow}\`](${OpenFileRevisionCommand.getMarkdownCommandArgs(
uri,
annotationType || FileAnnotationType.Blame,
this._options.line
)} "Blame Previous Revision") `;
}
if (this._options.remotes !== undefined && this._options.remotes.length !== 0) {
commands += `[\`${GlyphChars.ArrowUpRight}\`](${OpenCommitInRemoteCommand.getMarkdownCommandArgs(
this._item.sha
)} "Open in Remote") `;
}
commands += `[\`${GlyphChars.MiddleEllipsis}\`](${ShowQuickCommitFileDetailsCommand.getMarkdownCommandArgs(
this._item.sha
)} "Show More Actions")`;
return commands;
}
get date() {
return this._padOrTruncate(this._date, this._options.tokenOptions!.date);
}
get email() {
return this._padOrTruncate(this._item.email || '', this._options.tokenOptions!.email);
}
get id() {
return this._padOrTruncate(this._item.shortSha || '', this._options.tokenOptions!.id);
}
@ -116,7 +190,34 @@ export class CommitFormatter extends Formatter
message = message.replace(emojiRegex, (s, code) => emojiMap[code] || s);
}
return this._padOrTruncate(message, this._options.tokenOptions!.message);
message = this._padOrTruncate(message, this._options.tokenOptions!.message);
if (!this._options.markdown) {
return message;
}
if (this._options.remotes !== undefined) {
this._options.remotes.sort(
(a, b) =>
(a.default ? -1 : 1) - (b.default ? -1 : 1) ||
a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' })
);
for (const r of this._options.remotes) {
if (r.provider === undefined) continue;
message = r.provider.enrichMessage(message);
break;
}
}
return `\n\n> ${message
// Escape markdown
.replace(escapeMarkdownRegex, '\\$&')
// Escape markdown header (since the above regex won't match it)
.replace(/^===/gm, markdownHeaderReplacement)
// Keep under the same block-quote but with line breaks
.replace(/\n/g, '\t\n> ')}`;
}
get sha() {

+ 1
- 0
src/ui/config.ts Ver ficheiro

@ -50,6 +50,7 @@ export interface Config {
over: 'line' | 'annotation';
};
avatars: boolean;
detailsMarkdownFormat: string;
enabled: boolean;
};
insiders: boolean;

+ 1
- 1
src/views/nodes/commitNode.ts Ver ficheiro

@ -91,7 +91,7 @@ export class CommitNode extends ViewRefNode {
item.tooltip = CommitFormatter.fromTemplate(
this.commit.isUncommitted
? `\${author} ${GlyphChars.Dash} \${id}\n\${ago} (\${date})`
: `\${author} ${GlyphChars.Dash} \${id}${
: `\${author} \${(email) }${GlyphChars.Dash} \${id}${
branchAndTagTips !== undefined ? ` (${branchAndTagTips})` : ''
}\n\${ago} (\${date})\n\n\${message}`,
this.commit,

Carregando…
Cancelar
Guardar