From 6a5e00144428af4ecf8c87007e9af92cc538e041 Mon Sep 17 00:00:00 2001 From: Luxray5474 Date: Sat, 5 Jan 2019 22:54:24 -0500 Subject: [PATCH] Adds the option to change the length of the abbreviated commit SHA. --- README.md | 3 ++- package.json | 6 ++++++ src/git/git.ts | 4 ++-- src/ui/config.ts | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2d464ab..d103234 100644 --- a/README.md +++ b/README.md @@ -841,7 +841,8 @@ See also [View Settings](#view-settings- 'Jump to the View settings') ### Advanced Settings [#](#advanced-settings- 'Advanced Settings') | Name | Description | -| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | +| ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------| +| `gitlens.advanced.abbreviatedShaLength` | Specifies the length of the abbreviated commit SHA (a.k.a. commit ID). Default is 7. | `gitlens.advanced.blame.customArguments` | Specifies additional arguments to pass to the `git blame` command | | `gitlens.advanced.blame.delayAfterEdit` | Specifies the time (in milliseconds) to wait before re-blaming an unsaved document after an edit. Use 0 to specify an infinite wait | | `gitlens.advanced.blame.sizeThresholdAfterEdit` | Specifies the maximum document size (in lines) allowed to be re-blamed after an edit while still unsaved. Use 0 to specify no maximum | diff --git a/package.json b/package.json index 591fa50..ce20e88 100644 --- a/package.json +++ b/package.json @@ -1583,6 +1583,12 @@ "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 - `${path}` — full file path\n - `${working}` — optional indicator if the file is uncommitted", "scope": "window" }, + "gitlens.advanced.abbreviatedShaLength": { + "type": "number", + "default": "7", + "markdownDescription": "Specifies the length of the abbreviated commit SHA (a.k.a. commit ID). Default is 7.", + "scope": "window" + }, "gitlens.advanced.blame.customArguments": { "type": "array", "default": null, diff --git a/src/git/git.ts b/src/git/git.ts index 1428af3..8de4a15 100644 --- a/src/git/git.ts +++ b/src/git/git.ts @@ -285,9 +285,9 @@ export class Git { if (index > 5) { // Only grab a max of 5 chars for the suffix const suffix = ref.substring(index).substring(0, 5); - return `${ref.substring(0, 7 - suffix.length)}${suffix}`; + return `${ref.substring(0, Container.config.advanced.abbreviatedShaLength - suffix.length)}${suffix}`; } - return ref.substring(0, 7); + return ref.substring(0, Container.config.advanced.abbreviatedShaLength); } static splitPath(fileName: string, repoPath: string | undefined, extract: boolean = true): [string, string] { diff --git a/src/ui/config.ts b/src/ui/config.ts index af521f8..01d301e 100644 --- a/src/ui/config.ts +++ b/src/ui/config.ts @@ -186,6 +186,7 @@ export enum ViewFilesLayout { } export interface AdvancedConfig { + abbreviatedShaLength: number; blame: { customArguments: string[] | null; delayAfterEdit: number;