Skip to content

Commit 2319904

Browse files
committed
fix HEAD support for ado
1 parent 7fa56ef commit 2319904

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/web/src/app/[domain]/browse/[...path]/components/codePreviewPanel.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ export const CodePreviewPanel = async ({ path, repoName, revisionName, domain }:
3434
webUrl: repoInfoResponse.webUrl,
3535
});
3636

37+
// @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
38+
// will break if the default branch is not main.
39+
const fileWebUrl = repoInfoResponse.codeHostType === "azuredevops" && fileSourceResponse.webUrl ?
40+
fileSourceResponse.webUrl.replace("version=GBHEAD", "version=GBmain") : fileSourceResponse.webUrl;
41+
3742
return (
3843
<>
3944
<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 }:
4752
}}
4853
branchDisplayName={revisionName}
4954
/>
50-
{(fileSourceResponse.webUrl && codeHostInfo) && (
55+
56+
{(fileWebUrl && codeHostInfo) && (
57+
5158
<a
52-
href={fileSourceResponse.webUrl}
59+
href={fileWebUrl}
5360
target="_blank"
5461
rel="noopener noreferrer"
5562
className="flex flex-row items-center gap-2 px-2 py-0.5 rounded-md flex-shrink-0"

packages/web/src/features/search/searchApi.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,7 @@ export const search = async ({ query, matches, contextLines, whole }: SearchRequ
227227

228228
// If there are multiple branches pointing to the same revision of this file, it doesn't
229229
// matter which branch we use here, so use the first one.
230-
// @note: bitbucket and ado don't support using HEAD for the branch in links, so we default to main here
231-
const branch = file.Branches && file.Branches.length > 0 ? file.Branches[0] : "main";
230+
const branch = file.Branches && file.Branches.length > 0 ? file.Branches[0] : "HEAD";
232231
return getFileWebUrl(template, branch, file.FileName);
233232
})();
234233

0 commit comments

Comments
 (0)