fix HEAD support for ado

This commit is contained in:
msukkari 2025-09-17 22:11:01 -07:00
parent 7fa56efc77
commit 2319904173
2 changed files with 10 additions and 4 deletions

View file

@ -34,6 +34,11 @@ export const CodePreviewPanel = async ({ path, repoName, revisionName, domain }:
webUrl: repoInfoResponse.webUrl, webUrl: repoInfoResponse.webUrl,
}); });
// @todo: this is a hack to support linking to files for ADO. ADO doesn't support web urls with HEAD so we replace it with main. THis
// will break if the default branch is not main.
const fileWebUrl = repoInfoResponse.codeHostType === "azuredevops" && fileSourceResponse.webUrl ?
fileSourceResponse.webUrl.replace("version=GBHEAD", "version=GBmain") : fileSourceResponse.webUrl;
return ( return (
<> <>
<div className="flex flex-row py-1 px-2 items-center justify-between"> <div className="flex flex-row py-1 px-2 items-center justify-between">
@ -47,9 +52,11 @@ export const CodePreviewPanel = async ({ path, repoName, revisionName, domain }:
}} }}
branchDisplayName={revisionName} branchDisplayName={revisionName}
/> />
{(fileSourceResponse.webUrl && codeHostInfo) && (
{(fileWebUrl && codeHostInfo) && (
<a <a
href={fileSourceResponse.webUrl} href={fileWebUrl}
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
className="flex flex-row items-center gap-2 px-2 py-0.5 rounded-md flex-shrink-0" className="flex flex-row items-center gap-2 px-2 py-0.5 rounded-md flex-shrink-0"

View file

@ -227,8 +227,7 @@ export const search = async ({ query, matches, contextLines, whole }: SearchRequ
// If there are multiple branches pointing to the same revision of this file, it doesn't // If there are multiple branches pointing to the same revision of this file, it doesn't
// matter which branch we use here, so use the first one. // matter which branch we use here, so use the first one.
// @note: bitbucket and ado don't support using HEAD for the branch in links, so we default to main here const branch = file.Branches && file.Branches.length > 0 ? file.Branches[0] : "HEAD";
const branch = file.Branches && file.Branches.length > 0 ? file.Branches[0] : "main";
return getFileWebUrl(template, branch, file.FileName); return getFileWebUrl(template, branch, file.FileName);
})(); })();