Git - tag setting + better handling of not yet committed changes (#234221)

This commit is contained in:
Ladislau Szomoru 2024-11-19 23:03:29 +01:00 коммит произвёл GitHub
Родитель e2dbfd4dda
Коммит 6c8a8e24d2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

@ -3193,7 +3193,10 @@
"type": "boolean",
"default": false,
"markdownDescription": "%config.blameEditorDecoration.enabled%",
"scope": "resource"
"scope": "resource",
"tags": [
"experimental"
]
}
}
},

Просмотреть файл

@ -10,6 +10,8 @@ import { Repository } from './repository';
import { throttle } from './decorators';
import { BlameInformation } from './git';
const notCommittedYetId = '0000000000000000000000000000000000000000';
function isLineChanged(lineNumber: number, changes: readonly TextEditorDiff[]): boolean {
for (const change of changes) {
// If the change is a delete, skip it
@ -157,7 +159,7 @@ export class GitBlameController {
for (const lineNumber of textEditor.selections.map(s => s.active.line)) {
// Check if the line is in an add/edit change
if (isLineChanged(lineNumber + 1, diffInformation.diff)) {
decorations.push(this._createDecoration(lineNumber, l10n.t('Uncommitted change')));
decorations.push(this._createDecoration(lineNumber, l10n.t('Not Committed Yet')));
continue;
}
@ -170,8 +172,12 @@ export class GitBlameController {
});
if (blameInformation) {
const ago = fromNow(blameInformation.date ?? Date.now(), true, true);
decorations.push(this._createDecoration(lineNumber, `${blameInformation.message ?? ''}, ${blameInformation.authorName ?? ''} (${ago})`));
if (blameInformation.id === notCommittedYetId) {
decorations.push(this._createDecoration(lineNumber, l10n.t('Not Committed Yet')));
} else {
const ago = fromNow(blameInformation.date ?? Date.now(), true, true);
decorations.push(this._createDecoration(lineNumber, `${blameInformation.message ?? ''}, ${blameInformation.authorName ?? ''} (${ago})`));
}
}
}