Git - add git.commitShortHashLength setting (#237343)

This commit is contained in:
Ladislau Szomoru
2025-01-06 17:05:37 +01:00
committed by GitHub
parent 4e2ba23aed
commit 3548eae0e1
7 changed files with 53 additions and 30 deletions

View File

@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Event, Disposable, EventEmitter, SourceControlHistoryItemRef, l10n } from 'vscode';
import { Event, Disposable, EventEmitter, SourceControlHistoryItemRef, l10n, workspace, Uri } from 'vscode';
import { dirname, sep, relative } from 'path';
import { Readable } from 'stream';
import { promises as fs, createReadStream } from 'fs';
@@ -766,3 +766,9 @@ export function fromNow(date: number | Date, appendAgoLabel?: boolean, useFullTi
}
}
}
export function getCommitShortHash(scope: Uri, hash: string): string {
const config = workspace.getConfiguration('git', scope);
const shortHashLength = config.get<number>('commitShortHashLength', 7);
return hash.substring(0, shortHashLength);
}