diff --git a/README.md b/README.md index a374ebb..6135fd4 100644 --- a/README.md +++ b/README.md @@ -652,7 +652,7 @@ GitLens is highly customizable and provides many configuration settings to allow | `gitlens.defaultDateFormat` | Specifies how absolute dates will be formatted by default. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats | | `gitlens.defaultDateShortFormat` | Specifies how short absolute dates will be formatted by default. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats | | `gitlens.defaultDateStyle` | Specifies how dates will be displayed by default | -| `gitlens.defaultDateType` | Specifies if dates should use author date or committer date | +| `gitlens.defaultDateSource` | Specifies whether commit dates should use the authored or committed date | | `gitlens.defaultGravatarsStyle` | Specifies the style of the gravatar default (fallback) images

`identicon` - a geometric pattern
`mm` - a simple, cartoon-style silhouetted outline of a person (does not vary by email hash)
`monsterid` - a monster with different colors, faces, etc
`retro` - 8-bit arcade-style pixelated faces
`robohash` - a robot with different colors, faces, etc
`wavatar` - a face with differing features and backgrounds | | `gitlens.insiders` | Specifies whether to enable experimental features | | `gitlens.keymap` | Specifies the keymap to use for GitLens shortcut keys

`alternate` - adds an alternate set of shortcut keys that start with `Alt` (⌥ on macOS)
`chorded` - adds a chorded set of shortcut keys that start with `Ctrl+Shift+G` (⌥⌘G on macOS)
`none` - no shortcut keys will be added | @@ -664,45 +664,45 @@ 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

Available tokens
`${id}` — commit id
`${author}` — commit author
`${email}` — commit author e-mail
`${message}` — commit message
`${ago}` — relative commit date (e.g. 1 day ago)
`${date}` — formatted commit date (format specified by `gitlens.currentLine.dateFormat`)
`${agoOrDate}` — commit date specified by `gitlens.defaultDateStyle`
`${authorAgo}` — commit author, relative commit date
`${authorAgoOrDate}` — 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 (e.g. 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 [_Commit Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs. Date formatting is controlled by the `gitlens.currentLine.dateFormat` setting | +| `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

Available tokens
`${id}` — commit id
`${author}` — commit author
`${email}` — commit author e-mail
`${message}` — commit message
`${ago}` — relative commit date (e.g. 1 day ago)
`${date}` — formatted commit date (format specified by `gitlens.blame.dateFormat`)
`${agoOrDate}` — commit date specified by `gitlens.defaultDateStyle`
`${authorAgo}` — commit author, relative commit date
`${authorAgoOrDate}` — 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

`left` - adds a heatmap indicator on the left edge of the gutter blame annotations
`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

`gutter` - adds a gutter glyph
`line` - adds a full-line highlight background color
`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

`file` - toggles each file individually
`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 (e.g. 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 [_Commit Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs. Date formatting is controlled by the `gitlens.blame.dateFormat` setting | +| `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

`left` - adds a heatmap indicator on the left edge of the gutter blame annotations
`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

`gutter` - adds a gutter glyph
`line` - adds a full-line highlight background color
`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

`file` - toggles each file individually
`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

`annotation` - only shown when hovering over the line annotation
`line` - shown when hovering anywhere over the line | -| `gitlens.hovers.avatars` | Specifies whether to show avatar images in hovers | -| `gitlens.hovers.changesDiff` | Specifies whether to show just the changes to the line or the set of related changes in the _changes (diff)_ hover

`line` - Shows only the changes to the line

`hunk` - Shows the set of related changes | -| `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

`annotation` - only shown when hovering over the line annotation
`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

Available tokens
`${id}` — commit id
`${author}` — commit author
`${email}` — commit author e-mail
`${message}` — commit message
`${ago}` — relative commit date (e.g. 1 day ago)
`${date}` — formatted commit date (format specified by `gitlens.defaultDateFormat`)
`${agoOrDate}` — commit date specified by `gitlens.defaultDateStyle`
`${authorAgo}` — commit author, relative commit date
`${authorAgoOrDate}` — commit author, commit date specified by `gitlens.defaultDateStyle`
`${avatar}` — commit author avatar
`${commands}` — a set of commit commands | +| 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

`annotation` - only shown when hovering over the line annotation
`line` - shown when hovering anywhere over the line | +| `gitlens.hovers.avatars` | Specifies whether to show avatar images in hovers | +| `gitlens.hovers.changesDiff` | Specifies whether to show just the changes to the line or the set of related changes in the _changes (diff)_ hover

`line` - Shows only the changes to the line

`hunk` - Shows the set of related changes | +| `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

`annotation` - only shown when hovering over the line annotation
`line` - shown when hovering anywhere over the line | +| `gitlens.hovers.enabled` | Specifies whether to provide any hovers | +| `gitlens.hovers.detailsMarkdownFormat` | Specifies the format (in markdown) of the _commit details_ hover. See [_Commit Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs | ### Code Lens Settings [#](#code-lens-settings- 'Code Lens Settings') @@ -736,14 +736,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

`left` - aligns to the left
`right` - aligns to the right | -| `gitlens.statusBar.command` | Specifies the command to be executed when the blame status bar item is clicked

`gitlens.toggleFileBlame` - toggles file blame annotations
`gitlens.diffWithPrevious` - compares the current line commit with the previous
`gitlens.diffWithWorking` - compares the current line commit with the working tree
`gitlens.toggleCodeLens` - toggles Git code lens
`gitlens.showQuickCommitDetails` - shows a commit details quick pick
`gitlens.showQuickCommitFileDetails` - shows a commit file details quick pick
`gitlens.showQuickFileHistory` - shows a file history quick pick
`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

Available tokens
`${id}` — commit id
`${author}` — commit author
`${email}` — commit author e-mail
`${message}` — commit message
`${ago}` — relative commit date (e.g. 1 day ago)
`${date}` — formatted commit date (format specified by `gitlens.statusBar.dateFormat`)
`${agoOrDate}` — commit date specified by `gitlens.defaultDateStyle`
`${authorAgo}` — commit author, relative commit date
`${authorAgoOrDate}` — 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

`left` - aligns to the left
`right` - aligns to the right | +| `gitlens.statusBar.command` | Specifies the command to be executed when the blame status bar item is clicked

`gitlens.toggleFileBlame` - toggles file blame annotations
`gitlens.diffWithPrevious` - compares the current line commit with the previous
`gitlens.diffWithWorking` - compares the current line commit with the working tree
`gitlens.toggleCodeLens` - toggles Git code lens
`gitlens.showQuickCommitDetails` - shows a commit details quick pick
`gitlens.showQuickCommitFileDetails` - shows a commit file details quick pick
`gitlens.showQuickFileHistory` - shows a file history quick pick
`gitlens.showQuickRepoHistory` - shows a branch history quick pick | +| `gitlens.statusBar.dateFormat` | Specifies how to format absolute dates (e.g. using the `${date}` token) 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 [_Commit Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs. Date formatting is controlled by the `gitlens.statusBar.dateFormat` setting | +| `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') @@ -812,21 +812,21 @@ 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

Available tokens
`${directory}` — directory name
`${file}` — file name
`${filePath}` — formatted file name and path
`${path}` — full file path | -| `gitlens.views.commitFileDescriptionFormat` | Specifies the description format of a committed file in the views

Available tokens
`${directory}` — directory name
`${file}` — file name
`${filePath}` — formatted file name and path
`${path}` — 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

Available tokens
`${id}` — commit id
`${author}` — commit author
`${email}` — commit author e-mail
`${message}` — commit message
`${ago}` — relative commit date (e.g. 1 day ago)
`${date}` — formatted commit date (format specified by `gitlens.defaultDateFormat`)
`${agoOrDate}` — commit date specified by `gitlens.defaultDateStyle`
`${authorAgo}` — commit author, relative commit date
`${authorAgoOrDate}` — 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

Available tokens
`${id}` — commit id
`${author}` — commit author
`${email}` — commit author e-mail
`${message}` — commit message
`${ago}` — relative commit date (e.g. 1 day ago)
`${date}` — formatted commit date (format specified by `gitlens.defaultDateFormat`)
`${agoOrDate}` — commit date specified by `gitlens.defaultDateStyle`
`${authorAgo}` — commit author, relative commit date
`${authorAgoOrDate}` — 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.pageItemLimit` | Specifies the number of items to show in a each page when paginating 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

Available tokens
`${directory}` — directory name
`${file}` — file name
`${filePath}` — formatted file name and path
`${path}` — full file path | -| `gitlens.views.stashFileDescriptionFormat` | Specifies the description format of a stashed file in the views

Available tokens
`${directory}` — directory name
`${file}` — file name
`${filePath}` — formatted file name and path
`${path}` — 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

Available tokens
`${id}` — commit id
`${author}` — commit author
`${email}` — commit author e-mail
`${message}` — commit message
`${ago}` — relative commit date (e.g. 1 day ago)
`${date}` — formatted commit date (format specified by `gitlens.defaultDateFormat`)
`${agoOrDate}` — commit date specified by `gitlens.defaultDateStyle`
`${authorAgo}` — commit author, relative commit date
`${authorAgoOrDate}` — 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

Available tokens
`${id}` — commit id
`${author}` — commit author
`${email}` — commit author e-mail
`${message}` — commit message
`${ago}` — relative commit date (e.g. 1 day ago)
`${date}` — formatted commit date (format specified by `gitlens.defaultDateFormat`)
`${agoOrDate}` — commit date specified by `gitlens.defaultDateStyle`
`${authorAgo}` — commit author, relative commit date
`${authorAgoOrDate}` — 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

Available tokens
`${directory}` — directory name
`${file}` — file name
`${filePath}` — formatted file name and path
`${path}` — full file path
`${working}` — 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

Available tokens
`${directory}` — directory name
`${file}` — file name
`${filePath}` — formatted file name and path
`${path}` — full file path
`${working}` — optional indicator if the file is uncommitted | +| Name | Description | +| ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `gitlens.views.commitFileFormat` | Specifies the format of a committed file in the views. See [_File Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#file-tokens) in the GitLens docs | +| `gitlens.views.commitFileDescriptionFormat` | Specifies the description format of a committed file in the views. See [_File Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#file-tokens) in the GitLens docs | +| `gitlens.views.commitFormat` | Specifies the format of committed changes in the views. See [_Commit Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs | +| `gitlens.views.commitDescriptionFormat` | Specifies the description format of committed changes in the views. See [_Commit Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs | +| `gitlens.views.defaultItemLimit` | Specifies the default number of items to show in a view list. Use 0 to specify no limit | +| `gitlens.views.pageItemLimit` | Specifies the number of items to show in a each page when paginating 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. See [_File Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#file-tokens) in the GitLens docs | +| `gitlens.views.stashFileDescriptionFormat` | Specifies the description format of a stashed file in the views. See [_File Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#file-tokens) in the GitLens docs | +| `gitlens.views.stashFormat` | Specifies the format of stashed changes in the views. See [_Commit Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs | +| `gitlens.views.stashDescriptionFormat` | Specifies the description format of stashed changes in the views. See [_Commit Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs | +| `gitlens.views.statusFileFormat` | Specifies the format of the status of a working or committed file in the views. See [_File Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#file-tokens) in the GitLens docs | +| `gitlens.views.statusFileDescriptionFormat` | Specifies the description format of the status of a working or committed file in the views. See [_File Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#file-tokens) in the GitLens docs | ### Modes Settings [#](#modes-settings- 'Modes Settings') diff --git a/package.json b/package.json index 1703479..8402d43 100644 --- a/package.json +++ b/package.json @@ -68,13 +68,13 @@ "gitlens.blame.dateFormat": { "type": "string", "default": null, - "markdownDescription": "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", + "markdownDescription": "Specifies how to format absolute dates (e.g. using the `${date}` token) in gutter blame annotations. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats", "scope": "window" }, "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}` — 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#`", + "markdownDescription": "Specifies the format of the gutter blame annotations. See [_Commit Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs. Date formatting is controlled by the `#gitlens.blame.dateFormat#` setting", "scope": "window" }, "gitlens.blame.heatmap.enabled": { @@ -386,7 +386,7 @@ "gitlens.currentLine.dateFormat": { "type": "string", "default": null, - "markdownDescription": "Specifies how to format absolute dates (using the `${date}` token) for the current line blame annotation. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats", + "markdownDescription": "Specifies how to format absolute dates (e.g. using the `${date}` token) for the current line blame annotation. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats", "scope": "window" }, "gitlens.currentLine.enabled": { @@ -397,8 +397,8 @@ }, "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}` — 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#`", + "default": "${author}, ${agoOrDate} • ${message}", + "markdownDescription": "Specifies the format of the current line blame annotation. See [_Commit Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs. Date formatting is controlled by the `#gitlens.currentLine.dateFormat#` setting", "scope": "window" }, "gitlens.currentLine.scrollable": { @@ -425,32 +425,32 @@ "markdownDescription": "Specifies how short absolute dates will be formatted by default. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats", "scope": "window" }, - "gitlens.defaultDateStyle": { + "gitlens.defaultDateSource": { "type": "string", - "default": "relative", + "default": "authored", "enum": [ - "relative", - "absolute" + "authored", + "committed" ], "enumDescriptions": [ - "e.g. 1 day ago", - "e.g. July 25th, 2018 7:18pm" + "Uses the date when the changes were authored (i.e. originally written)", + "Uses the date when the changes were committed" ], - "markdownDescription": "Specifies how dates will be displayed by default", + "markdownDescription": "Specifies whether commit dates should use the authored or committed date", "scope": "window" }, - "gitlens.defaultDateType": { + "gitlens.defaultDateStyle": { "type": "string", - "default": "author", + "default": "relative", "enum": [ - "author", - "committer" + "relative", + "absolute" ], "enumDescriptions": [ - "The date that the commit was originally written", - "The date that the commit was applied to the branch" + "e.g. 1 day ago", + "e.g. July 25th, 2018 7:18pm" ], - "markdownDescription": "Specifies if dates should use author date or committer date", + "markdownDescription": "Specifies how dates will be displayed by default", "scope": "window" }, "gitlens.defaultGravatarsStyle": { @@ -594,7 +594,7 @@ "gitlens.hovers.detailsMarkdownFormat": { "type": "string", "default": "[${avatar}  __${author}__](mailto:${email}), ${ago}   _(${date})_ \n\n${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}` — 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", + "markdownDescription": "Specifies the format (in markdown) of the _commit details_ hover. See [_Commit Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs", "scope": "window" }, "gitlens.hovers.enabled": { @@ -1238,7 +1238,7 @@ "gitlens.statusBar.dateFormat": { "type": "string", "default": null, - "markdownDescription": "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", + "markdownDescription": "Specifies how to format absolute dates (e.g. using the `${date}` token) in the blame information in the status bar. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats", "scope": "window" }, "gitlens.statusBar.enabled": { @@ -1249,8 +1249,8 @@ }, "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}` — 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#`", + "default": "${author}, ${agoOrDate}", + "markdownDescription": "Specifies the format of the blame information in the status bar. See [_Commit Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs. Date formatting is controlled by the `#gitlens.statusBar.dateFormat#` setting", "scope": "window" }, "gitlens.statusBar.reduceFlicker": { @@ -1280,25 +1280,25 @@ "gitlens.views.commitFileFormat": { "type": "string", "default": "${file}", - "markdownDescription": "Specifies the format of a committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${originalPath}` — full file path of the original file if renamed\n - `${path}` — full file path", + "markdownDescription": "Specifies the format of a committed file in the views. See [_File Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#file-tokens) in the GitLens docs", "scope": "window" }, "gitlens.views.commitFileDescriptionFormat": { "type": "string", "default": "${directory}${ ← originalPath}", - "markdownDescription": "Specifies the description format of a committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${originalPath}` — full file path of the original file if renamed\n - `${path}` — full file path", + "markdownDescription": "Specifies the description format of a committed file in the views. See [_File Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#file-tokens) in the GitLens docs", "scope": "window" }, "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}` — 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#`", + "markdownDescription": "Specifies the format of committed changes in the views. See [_Commit Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs", "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}` — 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#`", + "default": "${changes • }${author}, ${agoOrDate}", + "markdownDescription": "Specifies the description format of committed changes in the views. See [_Commit Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs", "scope": "window" }, "gitlens.views.compare.avatars": { @@ -1590,37 +1590,37 @@ "gitlens.views.stashFileFormat": { "type": "string", "default": "${file}", - "markdownDescription": "Specifies the format of a stashed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${originalPath}` — full file path of the original file if renamed\n - `${path}` — full file path", + "markdownDescription": "Specifies the format of a stashed file in the views. See [_File Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#file-tokens) in the GitLens docs", "scope": "window" }, "gitlens.views.stashFileDescriptionFormat": { "type": "string", "default": "${directory}${ ← originalPath}", - "markdownDescription": "Specifies the description format of a stashed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${originalPath}` — full file path of the original file if renamed\n - `${path}` — full file path", + "markdownDescription": "Specifies the description format of a stashed file in the views. See [_File Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#file-tokens) in the GitLens docs", "scope": "window" }, "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}` — 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#`", + "markdownDescription": "Specifies the format of stashed changes in the views. See [_Commit Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs", "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}` — 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#`", + "markdownDescription": "Specifies the description format of stashed changes in the views. See [_Commit Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs", "scope": "window" }, "gitlens.views.statusFileFormat": { "type": "string", "default": "${working }${file}", - "markdownDescription": "Specifies the format of the status of a working or committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${originalPath}` — full file path of the original file if renamed\n - `${path}` — full file path\n - `${working}` — optional indicator if the file is uncommitted", + "markdownDescription": "Specifies the format of the status of a working or committed file in the views. See [_File Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#file-tokens) in the GitLens docs", "scope": "window" }, "gitlens.views.statusFileDescriptionFormat": { "type": "string", "default": "${directory}${ ← originalPath}", - "markdownDescription": "Specifies the description format of the status of a working or committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${originalPath}` — full file path of the original file if renamed\n - `${path}` — full file path\n - `${working}` — optional indicator if the file is uncommitted", + "markdownDescription": "Specifies the description format of the status of a working or committed file in the views. See [_File Tokens_](https://github.com/eamodio/vscode-gitlens/wiki/Custom-Formatting#file-tokens) in the GitLens docs", "scope": "window" }, "gitlens.advanced.abbreviatedShaLength": { diff --git a/src/codelens/codeLensController.ts b/src/codelens/codeLensController.ts index bfbded8..d439435 100644 --- a/src/codelens/codeLensController.ts +++ b/src/codelens/codeLensController.ts @@ -31,9 +31,9 @@ export class GitCodeLensController implements Disposable { const section = configuration.name('codeLens').value; if ( configuration.changed(e, section, null) || - configuration.changed(e, configuration.name('defaultDateStyle').value) || configuration.changed(e, configuration.name('defaultDateFormat').value) || - configuration.changed(e, configuration.name('defaultDateType').value) + configuration.changed(e, configuration.name('defaultDateSource').value) || + configuration.changed(e, configuration.name('defaultDateStyle').value) ) { if (!configuration.initializing(e)) { Logger.log('CodeLens config changed; resetting CodeLens provider'); diff --git a/src/config.ts b/src/config.ts index 5be13ed..2e27d5f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -29,8 +29,8 @@ export interface Config { debug: boolean; defaultDateFormat: string | null; defaultDateShortFormat: string | null; + defaultDateSource: DateSource; defaultDateStyle: DateStyle; - defaultDateType: DateType; defaultGravatarsStyle: GravatarDefaultStyle; heatmap: { ageThreshold: number; @@ -128,9 +128,9 @@ export enum CustomRemoteType { GitLab = 'GitLab' } -export enum DateType { - Author = 'author', - Committer = 'committer' +export enum DateSource { + Authored = 'authored', + Committed = 'committed' } export enum DateStyle { diff --git a/src/extension.ts b/src/extension.ts index c66c3c8..5fe8951 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -101,7 +101,37 @@ async function migrateSettings(context: ExtensionContext, previousVersion: strin const previous = Versions.fromString(previousVersion); try { - if (Versions.compare(previous, Versions.from(9, 2, 2)) !== 1) { + if (Versions.compare(previous, Versions.from(9, 6, 3)) !== 1) { + const formatMigrationFn = (v: string) => { + if (v == null || v.length === 0) return v; + + return ( + v + // eslint-disable-next-line no-template-curly-in-string + .replace(/\$\{authorAgo\}/g, '${author}, ${ago}') + // eslint-disable-next-line no-template-curly-in-string + .replace(/\$\{authorAgoOrDate\}/g, '${author}, ${agoOrDate}') + ); + }; + + await Promise.all( + [ + configuration.name('blame')('format').value, + configuration.name('currentLine')('format').value, + configuration.name('hovers')('detailsMarkdownFormat').value, + configuration.name('statusBar')('format').value, + configuration.name('views')('commitFormat').value, + configuration.name('views')('commitDescriptionFormat').value, + configuration.name('views')('stashFormat').value, + configuration.name('views')('stashDescriptionFormat').value + ].map(s => + configuration.migrate(s, s, { + migrationFn: formatMigrationFn + }) + ) + ); + } + else if (Versions.compare(previous, Versions.from(9, 2, 2)) !== 1) { await configuration.migrate('views.avatars', configuration.name('views')('compare')('avatars').value); await configuration.migrate('views.avatars', configuration.name('views')('repositories')('avatars').value); await configuration.migrate('views.avatars', configuration.name('views')('search')('avatars').value); diff --git a/src/git/formatters/commitFormatter.ts b/src/git/formatters/commitFormatter.ts index 285f20b..1923578 100644 --- a/src/git/formatters/commitFormatter.ts +++ b/src/git/formatters/commitFormatter.ts @@ -48,26 +48,54 @@ export interface CommitFormatOptions extends FormatOptions { } export class CommitFormatter extends Formatter { - private get _ago() { - return this._item.fromNow(); + private get _authorDate() { + return this._item.formatAuthorDate(this._options.dateFormat); + } + + private get _authorDateAgo() { + return this._item.formatAuthorDateFromNow(); + } + + private get _authorDateOrAgo() { + const dateStyle = + this._options.dateStyle !== undefined ? this._options.dateStyle : Container.config.defaultDateStyle; + return dateStyle === DateStyle.Absolute ? this._authorDate : this._authorDateAgo; + } + + private get _committerDate() { + return this._item.formatCommitterDate(this._options.dateFormat); + } + + private get _committerDateAgo() { + return this._item.formatCommitterDateFromNow(); + } + + private get _committerDateOrAgo() { + const dateStyle = + this._options.dateStyle !== undefined ? this._options.dateStyle : Container.config.defaultDateStyle; + return dateStyle === DateStyle.Absolute ? this._committerDate : this._committerDateAgo; } private get _date() { return this._item.formatDate(this._options.dateFormat); } - private get _agoOrDate() { + private get _dateAgo() { + return this._item.formatDateFromNow(); + } + + private get _dateOrAgo() { const dateStyle = this._options.dateStyle !== undefined ? this._options.dateStyle : Container.config.defaultDateStyle; - return dateStyle === DateStyle.Absolute ? this._date : this._ago; + return dateStyle === DateStyle.Absolute ? this._date : this._dateAgo; } get ago() { - return this._padOrTruncate(this._ago, this._options.tokenOptions.ago); + return this._padOrTruncate(this._dateAgo, this._options.tokenOptions.ago); } get agoOrDate() { - return this._padOrTruncate(this._agoOrDate, this._options.tokenOptions.agoOrDate); + return this._padOrTruncate(this._dateOrAgo, this._options.tokenOptions.agoOrDate); } get author() { @@ -75,13 +103,15 @@ export class CommitFormatter extends Formatter { } get authorAgo() { - const authorAgo = `${this._item.author}, ${this._ago}`; - return this._padOrTruncate(authorAgo, this._options.tokenOptions.authorAgo); + return this._padOrTruncate(this._authorDateAgo, this._options.tokenOptions.authorAgo); } get authorAgoOrDate() { - const authorAgo = `${this._item.author}, ${this._agoOrDate}`; - return this._padOrTruncate(authorAgo, this._options.tokenOptions.authorAgoOrDate); + return this._padOrTruncate(this._authorDateOrAgo, this._options.tokenOptions.authorAgoOrDate); + } + + get authorDate() { + return this._padOrTruncate(this._authorDate, this._options.tokenOptions.date); } get avatar() { @@ -158,6 +188,18 @@ export class CommitFormatter extends Formatter { return commands; } + get committerAgo() { + return this._padOrTruncate(this._committerDateAgo, this._options.tokenOptions.ago); + } + + get committerAgoOrDate() { + return this._padOrTruncate(this._committerDateOrAgo, this._options.tokenOptions.agoOrDate); + } + + get committerDate() { + return this._padOrTruncate(this._committerDate, this._options.tokenOptions.date); + } + get date() { return this._padOrTruncate(this._date, this._options.tokenOptions.date); } diff --git a/src/git/gitService.ts b/src/git/gitService.ts index 2a2600c..8cca575 100644 --- a/src/git/gitService.ts +++ b/src/git/gitService.ts @@ -167,9 +167,9 @@ export class GitService implements Disposable { private onConfigurationChanged(e: ConfigurationChangeEvent) { if ( - configuration.changed(e, configuration.name('defaultDateStyle').value) || configuration.changed(e, configuration.name('defaultDateFormat').value) || - configuration.changed(e, configuration.name('defaultDateType').value) + configuration.changed(e, configuration.name('defaultDateSource').value) || + configuration.changed(e, configuration.name('defaultDateStyle').value) ) { CommitFormatting.reset(); } diff --git a/src/git/models/commit.ts b/src/git/models/commit.ts index 97bbedf..267371e 100644 --- a/src/git/models/commit.ts +++ b/src/git/models/commit.ts @@ -1,13 +1,12 @@ 'use strict'; import { Uri } from 'vscode'; -import { configuration, DateStyle, GravatarDefaultStyle } from '../../configuration'; +import { configuration, DateSource, DateStyle, GravatarDefaultStyle } from '../../configuration'; import { Container } from '../../container'; import { Dates } from '../../system'; import { CommitFormatter } from '../formatters/formatters'; import { Git } from '../git'; import { GitUri } from '../gitUri'; import { getGravatarUri } from '../../gravatar'; -import { DateType } from '../../config'; export interface GitAuthor { name: string; @@ -32,13 +31,13 @@ export enum GitCommitType { export const CommitFormatting = { dateFormat: undefined! as string | null, + dateSource: undefined! as DateSource, dateStyle: undefined! as DateStyle, - dateType: undefined! as DateType, reset: () => { - CommitFormatting.dateStyle = configuration.get(configuration.name('defaultDateStyle').value); CommitFormatting.dateFormat = configuration.get(configuration.name('defaultDateFormat').value); - CommitFormatting.dateType = configuration.get(configuration.name('defaultDateType').value); + CommitFormatting.dateSource = configuration.get(configuration.name('defaultDateSource').value); + CommitFormatting.dateStyle = configuration.get(configuration.name('defaultDateStyle').value); } }; @@ -51,13 +50,12 @@ export abstract class GitCommit { protected readonly _fileName: string; protected _previousSha: string | undefined; + private _authorDateFormatter: Dates.DateFormatter | undefined; + private _committerDateFormatter: Dates.DateFormatter | undefined; private _isStagedUncommitted: boolean | undefined; private _isUncommitted: boolean | undefined; private _shortSha: string | undefined; - private _authorDateFormatter: Dates.DateFormatter | undefined; - private _committerDateFormatter: Dates.DateFormatter | undefined; - constructor( type: GitCommitType, public readonly repoPath: string, @@ -85,33 +83,13 @@ export abstract class GitCommit { } get date(): Date { - return CommitFormatting.dateType === DateType.Committer - ? this.committerDate : this.authorDate; - } - - get authorDateFormatter(): Dates.DateFormatter { - if (this._authorDateFormatter === undefined) { - this._authorDateFormatter = Dates.toFormatter(this.authorDate); - } - return this._authorDateFormatter; - } - - get committerDateFormatter(): Dates.DateFormatter { - if (this._committerDateFormatter === undefined) { - this._committerDateFormatter = Dates.toFormatter(this.committerDate); - } - return this._committerDateFormatter; - } - - get dateFormatter(): Dates.DateFormatter { - return CommitFormatting.dateType === DateType.Committer - ? this.committerDateFormatter : this.authorDateFormatter; + return CommitFormatting.dateSource === DateSource.Committed ? this.committerDate : this.authorDate; } get formattedDate(): string { return CommitFormatting.dateStyle === DateStyle.Absolute ? this.formatDate(CommitFormatting.dateFormat) - : this.fromNow(); + : this.formatDateFromNow(); } get shortSha() { @@ -180,6 +158,50 @@ export abstract class GitCommit { return this.workingFileName ? GitUri.resolveToUri(this.workingFileName, this.repoPath) : this.uri; } + private get authorDateFormatter(): Dates.DateFormatter { + if (this._authorDateFormatter === undefined) { + this._authorDateFormatter = Dates.toFormatter(this.authorDate); + } + return this._authorDateFormatter; + } + + private get committerDateFormatter(): Dates.DateFormatter { + if (this._committerDateFormatter === undefined) { + this._committerDateFormatter = Dates.toFormatter(this.committerDate); + } + return this._committerDateFormatter; + } + + private get dateFormatter(): Dates.DateFormatter { + return CommitFormatting.dateSource === DateSource.Committed + ? this.committerDateFormatter + : this.authorDateFormatter; + } + + formatAuthorDate(format?: string | null) { + if (format == null) { + format = 'MMMM Do, YYYY h:mma'; + } + + return this.authorDateFormatter.format(format); + } + + formatAuthorDateFromNow() { + return this.authorDateFormatter.fromNow(); + } + + formatCommitterDate(format?: string | null) { + if (format == null) { + format = 'MMMM Do, YYYY h:mma'; + } + + return this.committerDateFormatter.format(format); + } + + formatCommitterDateFromNow() { + return this.committerDateFormatter.fromNow(); + } + formatDate(format?: string | null) { if (format == null) { format = 'MMMM Do, YYYY h:mma'; @@ -188,7 +210,7 @@ export abstract class GitCommit { return this.dateFormatter.format(format); } - fromNow() { + formatDateFromNow() { return this.dateFormatter.fromNow(); } diff --git a/src/git/models/logCommit.ts b/src/git/models/logCommit.ts index 38a3fea..a25ac68 100644 --- a/src/git/models/logCommit.ts +++ b/src/git/models/logCommit.ts @@ -17,8 +17,8 @@ export class GitLogCommit extends GitCommit { sha: string, author: string, email: string | undefined, - date: Date, - public readonly committedDate: Date, + authorDate: Date, + committerDate: Date, message: string, fileName: string, public readonly files: GitFile[], @@ -34,8 +34,8 @@ export class GitLogCommit extends GitCommit { sha, author, email, - date, - committedDate, + authorDate, + committerDate, message, fileName, originalFileName, @@ -97,20 +97,24 @@ export class GitLogCommit extends GitCommit { return this._diff; } - getFormattedDiffStatus( - options: { - compact?: boolean; - empty?: string; - expand?: boolean; - prefix?: string; - separator?: string; - suffix?: string; - } = {} - ): string { + getFormattedDiffStatus({ + compact, + empty, + expand, + prefix = '', + separator = ' ', + suffix = '' + }: { + compact?: boolean; + empty?: string; + expand?: boolean; + prefix?: string; + separator?: string; + suffix?: string; + } = {}): string { const { added, changed, deleted } = this.getDiffStatus(); - if (added === 0 && changed === 0 && deleted === 0) return options.empty || ''; + if (added === 0 && changed === 0 && deleted === 0) return empty || ''; - const { compact, expand, prefix = '', separator = ' ', suffix = '' } = options; if (expand) { let status = ''; if (added) { @@ -170,7 +174,7 @@ export class GitLogCommit extends GitCommit { fileName?: string; author?: string; email?: string; - date?: Date; + authorDate?: Date; committedDate?: Date; message?: string; originalFileName?: string | null; @@ -185,8 +189,8 @@ export class GitLogCommit extends GitCommit { this.getChangedValue(changes.sha, this.sha)!, changes.author || this.author, changes.email || this.email, - changes.date || this.date, - changes.committedDate || this.committedDate, + changes.authorDate || this.authorDate, + changes.committedDate || this.committerDate, changes.message || this.message, changes.fileName || this.fileName, this.getChangedValue(changes.files, this.files) || [], diff --git a/src/git/models/stashCommit.ts b/src/git/models/stashCommit.ts index b0619af..19d2c1e 100644 --- a/src/git/models/stashCommit.ts +++ b/src/git/models/stashCommit.ts @@ -13,7 +13,7 @@ export class GitStashCommit extends GitLogCommit { public readonly stashName: string, repoPath: string, sha: string, - date: Date, + authorDate: Date, committedDate: Date, message: string, fileName: string, @@ -29,7 +29,7 @@ export class GitStashCommit extends GitLogCommit { sha, 'You', undefined, - date, + authorDate, committedDate, message, fileName, @@ -49,7 +49,7 @@ export class GitStashCommit extends GitLogCommit { type?: GitCommitType; sha?: string | null; fileName?: string; - date?: Date; + authorDate?: Date; committedDate?: Date; message?: string; originalFileName?: string | null; @@ -63,8 +63,8 @@ export class GitStashCommit extends GitLogCommit { this.stashName, this.repoPath, this.getChangedValue(changes.sha, this.sha)!, - changes.date || this.date, - changes.committedDate || this.committedDate, + changes.authorDate || this.authorDate, + changes.committedDate || this.committerDate, changes.message || this.message, changes.fileName || this.fileName, this.getChangedValue(changes.files, this.files) || [], diff --git a/src/git/models/status.ts b/src/git/models/status.ts index b2d8880..84f521a 100644 --- a/src/git/models/status.ts +++ b/src/git/models/status.ts @@ -62,20 +62,24 @@ export class GitStatus { return this._diff; } - getFormattedDiffStatus( - options: { - compact?: boolean; - empty?: string; - expand?: boolean; - prefix?: string; - separator?: string; - suffix?: string; - } = {} - ): string { + getFormattedDiffStatus({ + compact, + empty, + expand, + prefix = '', + separator = ' ', + suffix = '' + }: { + compact?: boolean; + empty?: string; + expand?: boolean; + prefix?: string; + separator?: string; + suffix?: string; + } = {}): string { const { added, changed, deleted } = this.getDiffStatus(); - if (added === 0 && changed === 0 && deleted === 0) return options.empty || ''; + if (added === 0 && changed === 0 && deleted === 0) return empty || ''; - const { compact, expand, prefix = '', separator = ' ', suffix = '' } = options; if (expand) { let status = ''; if (added) { diff --git a/src/system/string.ts b/src/system/string.ts index 17aeb86..e0a336f 100644 --- a/src/system/string.ts +++ b/src/system/string.ts @@ -51,8 +51,11 @@ export namespace Strings { export function getTokensFromTemplate(template: string) { const tokens: { key: string; options: TokenOptions }[] = []; - let match = tokenRegex.exec(template); - while (match != null) { + let match; + do { + match = tokenRegex.exec(template); + if (match == null) break; + const [, prefix, key, truncateTo, option, suffix] = match; tokens.push({ key: key, @@ -64,8 +67,7 @@ export namespace Strings { truncateTo: truncateTo == null ? undefined : parseInt(truncateTo, 10) } }); - match = tokenRegex.exec(template); - } + } while (match != null); return tokens; } diff --git a/src/views/nodes/helpers.ts b/src/views/nodes/helpers.ts index c22cc17..b7ded3c 100644 --- a/src/views/nodes/helpers.ts +++ b/src/views/nodes/helpers.ts @@ -55,7 +55,7 @@ export function* insertDateMarkers