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
committed by GitHub
parent e2dbfd4dda
commit 6c8a8e24d2
2 changed files with 13 additions and 4 deletions

View File

@@ -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})`));
}
}
}