Skip to content

Commit cd077e7

Browse files
committed
Fixes bad truncation on refs
1 parent 387e660 commit cd077e7

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

src/git/utils/reference.utils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ export function createReference(
2121
upstream?: { name: string; missing: boolean };
2222
},
2323
): GitBranchReference;
24-
export function createReference(
25-
ref: string,
26-
repoPath: string,
27-
options?: { refType: 'revision'; name?: string; message?: string },
28-
): GitRevisionReference;
2924
export function createReference(
3025
ref: string,
3126
repoPath: string,
@@ -36,6 +31,11 @@ export function createReference(
3631
repoPath: string,
3732
options: { refType: 'tag'; name: string; id?: string },
3833
): GitTagReference;
34+
export function createReference(
35+
ref: string,
36+
repoPath: string,
37+
options?: { refType: 'revision'; name?: string; message?: string },
38+
): GitRevisionReference;
3939
export function createReference(
4040
ref: string,
4141
repoPath: string,
@@ -87,7 +87,7 @@ export function createReference(
8787
repoPath: repoPath,
8888
ref: ref,
8989
sha: ref,
90-
name: options.name ?? shortenRevision(ref, { force: true, strings: { working: 'Working Tree' } }),
90+
name: options.name ?? shortenRevision(ref, { strings: { working: 'Working Tree' } }),
9191
message: options.message,
9292
};
9393
}

src/git/utils/revision.utils.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,17 @@ export function setAbbreviatedShaLength(length: number): void {
5454
export function shortenRevision(
5555
ref: string | undefined,
5656
options?: {
57-
force?: boolean;
5857
strings?: { uncommitted?: string; uncommittedStaged?: string; working?: string };
5958
},
6059
): string {
6160
if (ref === deletedOrMissing) return '(deleted)';
62-
6361
if (!ref) return options?.strings?.working ?? '';
6462
if (isUncommitted(ref)) {
6563
return isUncommittedStaged(ref)
6664
? options?.strings?.uncommittedStaged ?? 'Index'
6765
: options?.strings?.uncommitted ?? 'Working Tree';
6866
}
69-
70-
if (isRevisionRange(ref)) return ref;
71-
if (!options?.force && !isShaLike(ref)) return ref;
67+
if (isRevisionRange(ref) || !isShaLike(ref)) return ref;
7268

7369
// Don't allow shas to be shortened to less than 5 characters
7470
const len = Math.max(5, getAbbreviatedShaLength());

src/views/nodes/tagNode.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ export class TagNode extends ViewRefNode<'tag', ViewsWithTags, GitTagReference>
8383
item.id = this.id;
8484
item.contextValue = ContextValues.Tag;
8585
item.description = emojify(this.tag.message);
86-
item.tooltip = `${this.tag.name}${pad(GlyphChars.Dash, 2, 2)}${shortenRevision(this.tag.sha, {
87-
force: true,
88-
})}${
86+
item.tooltip = `${this.tag.name}${pad(GlyphChars.Dash, 2, 2)}${shortenRevision(this.tag.sha)}${
8987
this.tag.date != null
9088
? `\n${this.tag.formatDateFromNow()} (${this.tag.formatDate(
9189
this.view.container.TagDateFormatting.dateFormat,

0 commit comments

Comments
 (0)