Просмотр исходного кода

Closes #1987 uncommitted changes annotation format

main
Eric Amodio 2 лет назад
Родитель
Сommit
0300619526
9 измененных файлов: 113 добавлений и 16 удалений
  1. +3
    -1
      CHANGELOG.md
  2. +8
    -7
      README.md
  3. +7
    -0
      package.json
  4. +3
    -1
      src/annotations/lineAnnotationController.ts
  5. +1
    -0
      src/config.ts
  6. +57
    -0
      src/webviews/apps/settings/partials/current-line.html
  7. +16
    -3
      src/webviews/apps/shared/appWithConfigBase.ts
  8. +1
    -1
      src/webviews/protocol.ts
  9. +17
    -3
      src/webviews/webviewWithConfigBase.ts

+ 3
- 1
CHANGELOG.md Просмотреть файл

@ -20,8 +20,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Adds new stash behaviors to use the Source Control (commit message) input box — closes [#2081](https://github.com/gitkraken/vscode-gitlens/issues/2081)
- When a stash is applied or popped and the Source Control input is empty, we will now update the Source Control input to the stash message
- When stashing changes and the Source Control input is not empty, we will now default the stash message input to the Source Control input value
- Adds ability to search (<kbd>Ctrl</kbd>+<kbd>F</kbd>) for text on the Interactive Rebase Editor &mdash; closes [#2050](https://github.com/gitkraken/vscode-gitlens/issues/2050)
- Adds the ability to search (<kbd>Ctrl</kbd>+<kbd>F</kbd>) for text on the Interactive Rebase Editor &mdash; closes [#2050](https://github.com/gitkraken/vscode-gitlens/issues/2050)
- Adds stats (additions & deletions) to files nodes in comparisons &mdash; closes [#2078](https://github.com/gitkraken/vscode-gitlens/issues/2078) thanks to help via [PR #2079](https://github.com/gitkraken/vscode-gitlens/pull/2079) by Nafiur Rahman Khadem ([@ShafinKhadem](https://github.com/ShafinKhadem))
- Adds the ability to uniquely format uncommitted changes for the current line blame annotations &mdash; closes [#1987](https://github.com/gitkraken/vscode-gitlens/issues/1987)
- Adds a `gitlens.currentLine.uncommittedChangesFormat` setting to specify the uncommitted changes format of the current line blame annotation. **NOTE**: Setting this to an empty string will disable current line blame annotations for uncommitted changes
### Changed

+ 8
- 7
README.md Просмотреть файл

@ -714,13 +714,14 @@ 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 (e.g. using the `${date}` token) for the current line blame annotations. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for supported 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/gitkraken/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs. Date formatting is controlled by the `gitlens.currentLine.dateFormat` setting |
| `gitlens.currentLine.pullRequests.enabled` | Specifies whether to provide information about the Pull Request (if any) that introduced the commit in the current line blame annotation. Requires a connection to a supported remote service (e.g. GitHub) |
| `gitlens.currentLine.scrollable` | Specifies whether the current line blame annotation can be scrolled into view when it is outside the viewport. **NOTE**: Setting this to `false` will inhibit the hovers from showing over the annotation; Set `gitlens.hovers.currentLine.over` to `line` to enable the hovers to show anywhere over the line. |
| 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 supported 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/gitkraken/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs. Date formatting is controlled by the `gitlens.currentLine.dateFormat` setting |
| `gitlens.currentLine.uncommittedChangesFormat` | Specifies the uncommitted changes format of the current line blame annotation. See [_Commit Tokens_](https://github.com/gitkraken/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs. Date formatting is controlled by the `gitlens.currentLine.dateFormat` setting<br/><br/>**NOTE**: Setting this to an empty string will disable current line blame annotations for uncommitted changes. |
| `gitlens.currentLine.pullRequests.enabled` | Specifies whether to provide information about the Pull Request (if any) that introduced the commit in the current line blame annotation. Requires a connection to a supported remote service (e.g. GitHub) |
| `gitlens.currentLine.scrollable` | Specifies whether the current line blame annotation can be scrolled into view when it is outside the viewport. **NOTE**: Setting this to `false` will inhibit the hovers from showing over the annotation; Set `gitlens.hovers.currentLine.over` to `line` to enable the hovers to show anywhere over the line. |
## Git CodeLens Settings [#](#git-codelens-settings- 'Git CodeLens Settings')

+ 7
- 0
package.json Просмотреть файл

@ -250,6 +250,13 @@
"scope": "window",
"order": 30
},
"gitlens.currentLine.uncommittedChangesFormat": {
"type": "string",
"default": null,
"markdownDescription": "Specifies the uncommitted changes format of the current line blame annotation. See [_Commit Tokens_](https://github.com/gitkraken/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs. Date formatting is controlled by the `#gitlens.currentLine.dateFormat#` setting.\n\n**NOTE**: Setting this to an empty string will disable current line blame annotations for uncommitted changes.",
"scope": "window",
"order": 31
},
"gitlens.currentLine.scrollable": {
"type": "boolean",
"default": true,

+ 3
- 1
src/annotations/lineAnnotationController.ts Просмотреть файл

@ -297,11 +297,13 @@ export class LineAnnotationController implements Disposable {
const decorations = [];
for (const [l, commit] of commitLines) {
if (commit.isUncommitted && cfg.uncommittedChangesFormat === '') continue;
const decoration = Annotations.trailing(
commit,
// await GitUri.fromUri(editor.document.uri),
// l,
cfg.format,
commit.isUncommitted ? cfg.uncommittedChangesFormat ?? cfg.format : cfg.format,
{
dateFormat: cfg.dateFormat === null ? configuration.get('defaultDateFormat') : cfg.dateFormat,
getBranchAndTagTips: getBranchAndTagTips,

+ 1
- 0
src/config.ts Просмотреть файл

@ -28,6 +28,7 @@ export interface Config {
dateFormat: string | null;
enabled: boolean;
format: string;
uncommittedChangesFormat: string | null;
pullRequests: {
enabled: boolean;
};

+ 57
- 0
src/webviews/apps/settings/partials/current-line.html Просмотреть файл

@ -87,6 +87,63 @@
</div>
<div class="setting" data-enablement="currentLine.enabled">
<div class="setting__input setting__input--format">
<input
id="currentLine.useUncommittedChangesFormat"
name="currentLine.useUncommittedChangesFormat"
type="checkbox"
data-setting
disabled
/>
<label for="currentLine.useUncommittedChangesFormat"
>Override format for uncommitted changes</label
>
</div>
<span class="setting__hint" data-visibility="currentLine.useUncommittedChangesFormat =false"
>Example:
<span
data-setting-preview="currentLine.uncommittedChangesFormat"
data-setting-preview-type="commit-uncommitted"
data-setting-preview-default-lookup="currentLine.format"
></span>
</span>
</div>
<div
class="setting ml-2"
data-enablement="currentLine.enabled"
data-visibility="currentLine.useUncommittedChangesFormat"
>
<div class="setting__input setting__input--format">
<label for="currentLine.uncommittedChangesFormat"
>Uncommitted&nbsp;changes&nbsp;format</label
>
<input
id="currentLine.uncommittedChangesFormat"
name="currentLine.uncommittedChangesFormat"
type="text"
placeholder="format for uncommitted changes"
data-setting
data-setting-preview
data-default-value=""
data-popup-trigger
disabled
/>
<label for="currentLine.uncommittedChangesFormat" title="See available tokens">
<i class="icon icon__chevron-down"></i>
</label>
</div>
<div id="currentLine.uncommittedChangesFormat.popup" class="popup hidden"></div>
<span class="setting__hint" data-visibility="currentLine.useUncommittedChangesFormat"
>Example:
<span
data-setting-preview="currentLine.uncommittedChangesFormat"
data-setting-preview-type="commit-uncommitted"
data-setting-preview-default=""
></span>
</span>
</div>
<div class="setting" data-enablement="currentLine.enabled">
<div class="setting__input">
<input
id="currentLine.scrollable"

+ 16
- 3
src/webviews/apps/shared/appWithConfigBase.ts Просмотреть файл

@ -467,6 +467,11 @@ export abstract class AppWithConfig extends Ap
}
const state = flatten(this.state.config);
if (this.state.customSettings != null) {
for (const [key, value] of Object.entries(this.state.customSettings)) {
state[key] = value;
}
}
this.setVisibility(state);
this.setEnablement(state);
}
@ -507,7 +512,8 @@ export abstract class AppWithConfig extends Ap
}
private updatePreview(el: HTMLSpanElement, value?: string) {
switch (el.dataset.settingPreviewType) {
const previewType = el.dataset.settingPreviewType;
switch (previewType) {
case 'date': {
if (value === undefined) {
value = this.getSettingValue<string>(el.dataset.settingPreview!);
@ -537,13 +543,20 @@ export abstract class AppWithConfig extends Ap
}
break;
}
case 'commit': {
case 'commit':
case 'commit-uncommitted': {
if (value === undefined) {
value = this.getSettingValue<string>(el.dataset.settingPreview!);
}
if (!value) {
value = el.dataset.settingPreviewDefault;
if (value == null) {
const lookup = el.dataset.settingPreviewDefaultLookup;
if (lookup != null) {
value = this.getSettingValue<string>(lookup);
}
}
}
if (value == null) {
@ -556,7 +569,7 @@ export abstract class AppWithConfig extends Ap
GenerateConfigurationPreviewCommandType,
{
key: el.dataset.settingPreview!,
type: 'commit',
type: previewType,
format: value,
},
DidGenerateConfigurationPreviewNotificationType,

+ 1
- 1
src/webviews/protocol.ts Просмотреть файл

@ -43,7 +43,7 @@ export const ExecuteCommandType = new IpcCommandType('comm
export interface GenerateCommitPreviewParams {
key: string;
type: 'commit';
type: 'commit' | 'commit-uncommitted';
format: string;
}

+ 17
- 3
src/webviews/webviewWithConfigBase.ts Просмотреть файл

@ -140,16 +140,17 @@ export abstract class WebviewWithConfigBase extends WebviewBase {
onIpc(GenerateConfigurationPreviewCommandType, e, async params => {
switch (params.type) {
case 'commit': {
case 'commit':
case 'commit-uncommitted': {
const commit = new GitCommit(
this.container,
'~/code/eamodio/vscode-gitlens-demo',
'fe26af408293cba5b4bfd77306e1ac9ff7ccaef8',
new GitCommitIdentity('You', 'eamodio@gmail.com', new Date('2016-11-12T20:41:00.000Z')),
new GitCommitIdentity('You', 'eamodio@gmail.com', new Date('2020-11-01T06:57:21.000Z')),
'Supercharged',
params.type === 'commit-uncommitted' ? 'Uncommitted changes' : 'Supercharged',
['3ac1d3f51d7cf5f438cc69f25f6740536ad80fef'],
'Supercharged',
params.type === 'commit-uncommitted' ? 'Uncommitted changes' : 'Supercharged',
new GitFileChange(
'~/code/eamodio/vscode-gitlens-demo',
'code.ts',
@ -225,6 +226,19 @@ export abstract class WebviewWithConfigBase extends WebviewBase {
update: this.container.rebaseEditor.setEnabled,
},
],
[
'currentLine.useUncommittedChangesFormat',
{
name: 'currentLine.useUncommittedChangesFormat',
enabled: () => configuration.get('currentLine.uncommittedChangesFormat') != null,
update: async enabled =>
configuration.updateEffective(
'currentLine.uncommittedChangesFormat',
// eslint-disable-next-line no-template-curly-in-string
enabled ? '✏️ ${ago}' : null,
),
},
],
]);
}
return this._customSettings;

Загрузка…
Отмена
Сохранить