Only use the commit in share link when upstream (#156658)

Fixes #156627
This commit is contained in:
Alex Ross
2022-07-29 12:30:05 +02:00
committed by GitHub
parent 84dc769b20
commit 12b08be500

View File

@@ -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}`;
}