From 191a17e02b9792b47607c717d8852089700e11bf Mon Sep 17 00:00:00 2001 From: Ramin Tadayon Date: Wed, 22 Feb 2023 11:58:38 -0700 Subject: [PATCH] Fixes remote branch deep link generation and resolving logic --- src/uris/deepLinks/deepLinkService.ts | 13 +++++++++++-- src/webviews/apps/plus/graph/GraphWrapper.tsx | 5 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/uris/deepLinks/deepLinkService.ts b/src/uris/deepLinks/deepLinkService.ts index b24821a..dfe4446 100644 --- a/src/uris/deepLinks/deepLinkService.ts +++ b/src/uris/deepLinks/deepLinkService.ts @@ -2,6 +2,7 @@ import { Disposable, env, ProgressLocation, Uri, window, workspace } from 'vscod import { configuration } from '../../configuration'; import { Commands } from '../../constants'; import type { Container } from '../../container'; +import { getBranchNameWithoutRemote } from '../../git/models/branch'; import { GitReference } from '../../git/models/reference'; import type { GitRemote } from '../../git/models/remote'; import { parseGitRemoteUrl } from '../../git/parsers/remoteParser'; @@ -134,7 +135,13 @@ export class DeepLinkService implements Disposable { if (targetType === DeepLinkType.Branch) { // Form the target branch name using the remote name and branch name const branchName = `${remote.name}/${targetId}`; - const branch = await repo.getBranch(branchName); + let branch = await repo.getBranch(branchName); + if (branch) { + return branch.sha; + } + + // If it doesn't exist on the target remote, it may still exist locally. + branch = await repo.getBranch(targetId); if (branch) { return branch.sha; } @@ -501,7 +508,9 @@ export class DeepLinkService implements Disposable { switch (refOrRepoPath.refType) { case 'branch': targetType = DeepLinkType.Branch; - targetId = refOrRepoPath.name; + targetId = refOrRepoPath.remote + ? getBranchNameWithoutRemote(refOrRepoPath.name) + : refOrRepoPath.name; break; case 'revision': targetType = DeepLinkType.Commit; diff --git a/src/webviews/apps/plus/graph/GraphWrapper.tsx b/src/webviews/apps/plus/graph/GraphWrapper.tsx index 5188b71..df4c7fe 100644 --- a/src/webviews/apps/plus/graph/GraphWrapper.tsx +++ b/src/webviews/apps/plus/graph/GraphWrapper.tsx @@ -529,8 +529,9 @@ export function GraphWrapper({ if ( !graphConfig?.minimap || !graphConfig.enabledMinimapMarkerTypes?.includes(GraphMinimapMarkerTypes.Highlights) - ) - {return undefined;} + ) { + return undefined; + } const searchResultsByDay = new Map();