From 12b08be500f8a307f30e92cbc3ee39ba115eab69 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Fri, 29 Jul 2022 12:30:05 +0200 Subject: [PATCH] Only use the commit in share link when upstream (#156658) Fixes #156627 --- extensions/github/src/links.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/github/src/links.ts b/extensions/github/src/links.ts index 22ede57ccbd..66f5b071ecd 100644 --- a/extensions/github/src/links.ts +++ b/extensions/github/src/links.ts @@ -125,11 +125,11 @@ export function getPermalink(gitAPI: GitAPI, useSelection: boolean, hostPrefix?: return; } - const commitHash = gitRepo.state.HEAD?.commit; + const commitHash = (gitRepo.state.HEAD?.ahead === 0) ? `/blob/${gitRepo.state.HEAD?.commit}` : ''; const fileSegments = fileAndPosition.type === LinkType.File ? (useSelection ? `${uri.path.substring(gitRepo.rootUri.path.length)}${rangeString(fileAndPosition.range)}` : '') : (useSelection ? `${uri.path.substring(gitRepo.rootUri.path.length)}${notebookCellRangeString(fileAndPosition.cellIndex, fileAndPosition.range)}` : ''); - return `${hostPrefix}/${repo.owner}/${repo.repo}/blob/${commitHash + return `${hostPrefix}/${repo.owner}/${repo.repo}${commitHash }${fileSegments}`; }