mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-13 21:05:22 +00:00
fix HEAD support for ado
This commit is contained in:
parent
7fa56efc77
commit
2319904173
2 changed files with 10 additions and 4 deletions
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue