Skip to content

Commit 6a5e001

Browse files
Luxray5474eamodio
authored andcommitted
Adds the option to change the length of the abbreviated commit SHA.
1 parent 4816809 commit 6a5e001

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,8 @@ See also [View Settings](#view-settings- 'Jump to the View settings')
841841
### Advanced Settings [#](#advanced-settings- 'Advanced Settings')
842842

843843
| Name | Description |
844-
| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
844+
| ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------|
845+
| `gitlens.advanced.abbreviatedShaLength` | Specifies the length of the abbreviated commit SHA (a.k.a. commit ID). Default is 7.
845846
| `gitlens.advanced.blame.customArguments` | Specifies additional arguments to pass to the `git blame` command |
846847
| `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 |
847848
| `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 |

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,12 @@
15831583
"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",
15841584
"scope": "window"
15851585
},
1586+
"gitlens.advanced.abbreviatedShaLength": {
1587+
"type": "number",
1588+
"default": "7",
1589+
"markdownDescription": "Specifies the length of the abbreviated commit SHA (a.k.a. commit ID). Default is 7.",
1590+
"scope": "window"
1591+
},
15861592
"gitlens.advanced.blame.customArguments": {
15871593
"type": "array",
15881594
"default": null,

src/git/git.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,9 @@ export class Git {
285285
if (index > 5) {
286286
// Only grab a max of 5 chars for the suffix
287287
const suffix = ref.substring(index).substring(0, 5);
288-
return `${ref.substring(0, 7 - suffix.length)}${suffix}`;
288+
return `${ref.substring(0, Container.config.advanced.abbreviatedShaLength - suffix.length)}${suffix}`;
289289
}
290-
return ref.substring(0, 7);
290+
return ref.substring(0, Container.config.advanced.abbreviatedShaLength);
291291
}
292292

293293
static splitPath(fileName: string, repoPath: string | undefined, extract: boolean = true): [string, string] {

src/ui/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ export enum ViewFilesLayout {
186186
}
187187

188188
export interface AdvancedConfig {
189+
abbreviatedShaLength: number;
189190
blame: {
190191
customArguments: string[] | null;
191192
delayAfterEdit: number;

0 commit comments

Comments
 (0)