Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [ask sb] Fixed issue where reasoning tokens would appear in `text` content for openai compatible models. [#582](https://github.com/sourcebot-dev/sourcebot/pull/582)
- Fixed issue with GitHub app token tracking and refreshing. [#583](https://github.com/sourcebot-dev/sourcebot/pull/583)
- Fixed "The account is already associated with another user" errors with GitLab oauth provider. [#584](https://github.com/sourcebot-dev/sourcebot/pull/584)
- Fixed error when viewing a generic git connection in `/settings/connections`. [#588](https://github.com/sourcebot-dev/sourcebot/pull/588)

## [4.8.1] - 2025-10-29

Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/constants.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
import { CodeHostType } from "@sourcebot/db";
import { env } from "./env.js";
import path from "path";

export const SINGLE_TENANT_ORG_ID = 1;

export const PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES = [
export const PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES: CodeHostType[] = [
'github',
'gitlab',
];
Expand Down
11 changes: 6 additions & 5 deletions packages/backend/src/repoCompileUtils.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@ import { BitbucketRepository, getBitbucketReposFromConfig } from "./bitbucket.js
import { getAzureDevOpsReposFromConfig } from "./azuredevops.js";
import { SchemaRestRepository as BitbucketServerRepository } from "@coderabbitai/bitbucket/server/openapi";
import { SchemaRepository as BitbucketCloudRepository } from "@coderabbitai/bitbucket/cloud/openapi";
import { Prisma, PrismaClient } from '@sourcebot/db';
import { CodeHostType, Prisma, PrismaClient } from '@sourcebot/db';
import { WithRequired } from "./types.js"
import { marshalBool } from "./utils.js";
import { createLogger } from '@sourcebot/logger';
Expand DownExpand Up@@ -392,7 +392,7 @@ export const compileBitbucketConfig = async (

const repos = bitbucketRepos.map((repo) => {
const isServer = config.deploymentType === 'server';
const codeHostType= isServer ? 'bitbucket-server' : 'bitbucket-cloud'; // zoekt expects bitbucket-server
const codeHostType: CodeHostType = isServer ? 'bitbucketServer' : 'bitbucketCloud';
const displayName = isServer ? (repo as BitbucketServerRepository).name! : (repo as BitbucketCloudRepository).full_name!;
const externalId = isServer ? (repo as BitbucketServerRepository).id!.toString() : (repo as BitbucketCloudRepository).uuid!;
const isPublic = isServer ? (repo as BitbucketServerRepository).public : (repo as BitbucketCloudRepository).is_private === false;
Expand DownExpand Up@@ -425,7 +425,8 @@ export const compileBitbucketConfig = async (
},
metadata: {
gitConfig: {
'zoekt.web-url-type': codeHostType,
// zoekt expects bitbucket-server and bitbucket-cloud
'zoekt.web-url-type': codeHostType === 'bitbucketServer' ? 'bitbucket-server' : 'bitbucket-cloud',
'zoekt.web-url': webUrl,
'zoekt.name': repoName,
'zoekt.archived': marshalBool(isArchived),
Expand DownExpand Up@@ -507,7 +508,7 @@ export const compileGenericGitHostConfig_file = async (
const repoName = path.join(remoteUrl.host, remoteUrl.pathname.replace(/\.git$/, ''));

const repo: RepoData = {
external_codeHostType: 'generic-git-host',
external_codeHostType: 'genericGitHost',
external_codeHostUrl: remoteUrl.resource,
external_id: remoteUrl.toString(),
cloneUrl: `file://${repoPath}`,
Expand DownExpand Up@@ -571,7 +572,7 @@ export const compileGenericGitHostConfig_url = async (
const repoName = path.join(remoteUrl.host, remoteUrl.pathname.replace(/\.git$/, ''));

const repo: RepoData = {
external_codeHostType: 'generic-git-host',
external_codeHostType: 'genericGitHost',
external_codeHostUrl: remoteUrl.origin,
external_id: remoteUrl.toString(),
cloneUrl: remoteUrl.toString(),
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/utils.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,7 +59,7 @@ export const getRepoPath = (repo: Repo): { path: string, isReadOnly: boolean } =
// If we are dealing with a local repository, then use that as the path.
// Mark as read-only since we aren't guaranteed to have write access to the local filesystem.
const cloneUrl = new URL(repo.cloneUrl);
if (repo.external_codeHostType === 'generic-git-host' && cloneUrl.protocol === 'file:') {
if (repo.external_codeHostType === 'genericGitHost' && cloneUrl.protocol === 'file:') {
return {
path: cloneUrl.pathname,
isReadOnly: true,
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
/*
Migrates the `connectionType` column from text to a enum. The values in this field are known to
be one of the following: github, gitlab, gitea, gerrit, bitbucket, azuredevops, git.

This is occording to what we would expect to be in a valid config file for the schema version at commit 4899c9fbc755851af2ddcce99f4a4200f2faa4f6.
See: https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/schemas/src/v3/connection.type.ts#L3
*/
-- CreateEnum
CREATE TYPE "ConnectionType" AS ENUM ('github', 'gitlab', 'gitea', 'gerrit', 'bitbucket', 'azuredevops', 'git');

-- AlterTable - Convert existing column to enum type without dropping data
ALTER TABLE "Connection"
ALTER COLUMN "connectionType" TYPE "ConnectionType"
USING "connectionType"::text::"ConnectionType";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
/*
Migrates the `external_codeHostType` column from text to a enum. The values in this field are known to
be one of the following: github, gitlab, gitea, gerrit, bitbucket-server, bitbucket-cloud, generic-git-host, azuredevops.

This is occording to what we would expect to be in the database written as of commit 4899c9fbc755851af2ddcce99f4a4200f2faa4f6.
See:
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L57
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L135
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L208
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L291
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L407
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L510
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L574
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L642
*/
-- CreateEnum
CREATE TYPE "CodeHostType" AS ENUM ('github', 'gitlab', 'gitea', 'gerrit', 'bitbucket-server', 'bitbucket-cloud', 'generic-git-host', 'azuredevops');

-- AlterTable - Convert existing column to enum type without dropping data
ALTER TABLE "Repo"
ALTER COLUMN "external_codeHostType" TYPE "CodeHostType"
USING "external_codeHostType"::text::"CodeHostType";
31 changes: 29 additions & 2 deletions packages/db/prisma/schema.prisma
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,21 @@ enum ChatVisibility {
PUBLIC
}

/// @note: The @map annotation is required to maintain backwards compatibility
/// with the existing database.
/// @note: In the generated client, these mapped values will be in pascalCase.
/// This behaviour will change in prisma v7. See: https://github.com/prisma/prisma/issues/8446#issuecomment-3356119713
enum CodeHostType {
github
gitlab
gitea
gerrit
bitbucketServer @map("bitbucket-server")
bitbucketCloud @map("bitbucket-cloud")
genericGitHost @map("generic-git-host")
azuredevops
}

model Repo {
id Int @id @default(autoincrement())
name String /// Full repo name, including the vcs hostname (ex. github.com/sourcebot-dev/sourcebot)
Expand All@@ -53,7 +68,7 @@ model Repo {
indexedCommitHash String? /// The commit hash of the last indexed commit (on HEAD).

external_id String /// The id of the repo in the external service
external_codeHostType String /// The type of the external service (e.g., github, gitlab, etc.)
external_codeHostType CodeHostType /// The type of the external service (e.g., github, gitlab, etc.)
external_codeHostUrl String /// The base url of the external service (e.g., https://github.com)

org Org @relation(fields: [orgId], references: [id], onDelete: Cascade)
Expand DownExpand Up@@ -125,6 +140,18 @@ model SearchContext {
@@unique([name, orgId])
}

/// Matches the union of `type` fields in the schema.
/// @see: schemas/v3/connection.type.ts
enum ConnectionType {
github
gitlab
gitea
gerrit
bitbucket
azuredevops
git
}

model Connection {
id Int @id @default(autoincrement())
name String
Expand All@@ -135,7 +162,7 @@ model Connection {
repos RepoToConnection[]

// The type of connection (e.g., github, gitlab, etc.)
connectionType String
connectionType ConnectionType

syncJobs ConnectionSyncJob[]
/// When the connection was last synced successfully.
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ export const CodePreviewPanel = async ({ path, repoName, revisionName }: CodePre
branchDisplayName={revisionName}
/>

{(fileWebUrl && codeHostInfo) && (
{fileWebUrl && (

<a
href={fileWebUrl}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,9 +7,10 @@ import { Badge } from "@/components/ui/badge";
import { Card } from "@/components/ui/card";
import { CardContent } from "@/components/ui/card";
import { DemoExamples, DemoSearchExample, DemoSearchScope } from "@/types";
import { cn, CodeHostType, getCodeHostIcon } from "@/lib/utils";
import { cn, getCodeHostIcon } from "@/lib/utils";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { SearchScopeInfoCard } from "@/features/chat/components/chatBox/searchScopeInfoCard";
import { CodeHostType } from "@sourcebot/db";

interface DemoCards {
demoExamples: DemoExamples;
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/app/[domain]/components/configEditor.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,8 +12,8 @@ import { Separator } from "@/components/ui/separator";
import { Schema } from "ajv";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { CodeHostType } from "@/lib/utils";
import { useCodeMirrorTheme } from "@/hooks/useCodeMirrorTheme";
import { CodeHostType } from "@sourcebot/db";

export type QuickActionFn<T> = (previous: T) => T;
export type QuickAction<T> = {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,10 +9,11 @@ import { Input } from "@/components/ui/input";
import { Separator } from "@/components/ui/separator";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { useDomain } from "@/hooks/useDomain";
import { CodeHostType, isServiceError } from "@/lib/utils";
import { isServiceError } from "@/lib/utils";
import githubPatCreation from "@/public/github_pat_creation.png";
import gitlabPatCreation from "@/public/gitlab_pat_creation.png";
import giteaPatCreation from "@/public/gitea_pat_creation.png";
import { CodeHostType } from "@sourcebot/db";
import { zodResolver } from "@hookform/resolvers/zod";
import { Eye, EyeOff, Loader2 } from "lucide-react";
import Image from "next/image";
Expand DownExpand Up@@ -88,9 +89,9 @@ export const ImportSecretDialog = ({ open, onOpenChange, onSecretCreated, codeHo
return <GitHubPATCreationStep step={1} />;
case 'gitlab':
return <GitLabPATCreationStep step={1} />;
case 'bitbucket-cloud':
case 'bitbucketCloud':
return <BitbucketCloudPATCreationStep step={1} />;
case 'bitbucket-server':
case 'bitbucketServer':
return <BitbucketServerPATCreationStep step={1} />;
case 'gitea':
return <GiteaPATCreationStep step={1} />;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@ import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants";
import { RepositoryQuery } from "@/lib/types";
import { getCodeHostInfoForRepo, getShortenedNumberDisplayString } from "@/lib/utils";
import clsx from "clsx";
import { FileIcon, Loader2Icon, RefreshCwIcon } from "lucide-react";
import { Loader2Icon, RefreshCwIcon } from "lucide-react";
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/navigation";
Expand DownExpand Up@@ -90,23 +90,14 @@ const RepoItem = ({ repo }: { repo: RepositoryQuery }) => {
webUrl: repo.webUrl,
});

if (info) {
return {
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}
}

return {
repoIcon: <FileIcon className="w-4 h-4" />,
displayName: repo.repoName,
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}


}, [repo.repoName, repo.codeHostType, repo.repoDisplayName, repo.webUrl]);


Expand Down
22 changes: 9 additions & 13 deletions packages/web/src/app/[domain]/components/pathHeader.tsx
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
'use client';

import { cn, getCodeHostInfoForRepo } from "@/lib/utils";
import { LaptopIcon } from "@radix-ui/react-icons";
import Image from "next/image";
import { getBrowsePath } from "../browse/hooks/utils";
import { ChevronRight, MoreHorizontal } from "lucide-react";
Expand All@@ -17,6 +16,7 @@ import { VscodeFileIcon } from "@/app/components/vscodeFileIcon";
import { CopyIconButton } from "./copyIconButton";
import Link from "next/link";
import { useDomain } from "@/hooks/useDomain";
import { CodeHostType } from "@sourcebot/db";

interface FileHeaderProps {
path: string;
Expand All@@ -27,7 +27,7 @@ interface FileHeaderProps {
pathType?: 'blob' | 'tree';
repo: {
name: string;
codeHostType: string;
codeHostType: CodeHostType;
displayName?: string;
webUrl?: string;
},
Expand DownExpand Up@@ -202,17 +202,13 @@ export const PathHeader = ({
<div className="flex flex-row gap-2 items-center w-full overflow-hidden">
{isCodeHostIconVisible && (
<>
{info?.icon ? (
<a href={info.repoLink} target="_blank" rel="noopener noreferrer">
<Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>
</a>
) : (
<LaptopIcon className="w-4 h-4" />
)}
<a href={info.repoLink} target="_blank" rel="noopener noreferrer">
<Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>
</a>
</>
)}

Expand Down
20 changes: 6 additions & 14 deletions packages/web/src/app/[domain]/components/repositoryCarousel.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,6 @@ import {
import { captureEvent } from "@/hooks/useCaptureEvent";
import { RepositoryQuery } from "@/lib/types";
import { getCodeHostInfoForRepo } from "@/lib/utils";
import { FileIcon } from "@radix-ui/react-icons";
import clsx from "clsx";
import Autoscroll from "embla-carousel-auto-scroll";
import Image from "next/image";
Expand DownExpand Up@@ -121,20 +120,13 @@ const RepositoryBadge = ({
webUrl: repo.webUrl,
});

if (info) {
return {
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}
}

return {
repoIcon: <FileIcon className="w-4 h-4" />,
displayName: repo.repoName,
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
Comment thread
brendan-kellam marked this conversation as resolved.
}
})();

Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/app/[domain]/repos/[id]/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,7 +65,7 @@ export default async function RepoDetailPage({ params }: { params: Promise<{ id:
<h1 className="text-3xl font-semibold">{repo.displayName || repo.name}</h1>
<p className="text-muted-foreground mt-2">{repo.name}</p>
</div>
{(codeHostInfo && codeHostInfo.repoLink) && (
{codeHostInfo.repoLink && (
<Button variant="outline" asChild>
<Link href={codeHostInfo.repoLink} target="_blank" rel="noopener noreferrer" className="flex items-center">
<Image
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,13 +15,14 @@ import {
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { CodeHostType, getCodeHostBrowseAtBranchUrl } from "@/lib/utils"
import { getCodeHostBrowseAtBranchUrl } from "@/lib/utils"
import Link from "next/link"
import { CodeHostType } from "@sourcebot/db";

type RepoBranchesTableProps = {
indexRevisions: string[];
repoWebUrl: string | null;
repoCodeHostType: string;
repoCodeHostType: CodeHostType;
}

export const RepoBranchesTable = ({ indexRevisions, repoWebUrl, repoCodeHostType }: RepoBranchesTableProps) => {
Expand All@@ -39,7 +40,7 @@ export const RepoBranchesTable = ({ indexRevisions, repoWebUrl, repoCodeHostType

const branchUrl = getCodeHostBrowseAtBranchUrl({
webUrl: repoWebUrl,
codeHostType: repoCodeHostType as CodeHostType,
codeHostType: repoCodeHostType,
branchName: refName,
});

Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all \u003cpre\u003e\u003ccode\u003e blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks"); } } catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); } })(); (function(){ try { var __m = "github.com"; var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [ask sb] Fixed issue where reasoning tokens would appear in `text` content for openai compatible models. [#582](https://github.com/sourcebot-dev/sourcebot/pull/582)
- Fixed issue with GitHub app token tracking and refreshing. [#583](https://github.com/sourcebot-dev/sourcebot/pull/583)
- Fixed "The account is already associated with another user" errors with GitLab oauth provider. [#584](https://github.com/sourcebot-dev/sourcebot/pull/584)
- Fixed error when viewing a generic git connection in `/settings/connections`. [#588](https://github.com/sourcebot-dev/sourcebot/pull/588)

## [4.8.1] - 2025-10-29

Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/constants.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
import { CodeHostType } from "@sourcebot/db";
import { env } from "./env.js";
import path from "path";

export const SINGLE_TENANT_ORG_ID = 1;

export const PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES = [
export const PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES: CodeHostType[] = [
'github',
'gitlab',
];
Expand Down
11 changes: 6 additions & 5 deletions packages/backend/src/repoCompileUtils.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@ import { BitbucketRepository, getBitbucketReposFromConfig } from "./bitbucket.js
import { getAzureDevOpsReposFromConfig } from "./azuredevops.js";
import { SchemaRestRepository as BitbucketServerRepository } from "@coderabbitai/bitbucket/server/openapi";
import { SchemaRepository as BitbucketCloudRepository } from "@coderabbitai/bitbucket/cloud/openapi";
import { Prisma, PrismaClient } from '@sourcebot/db';
import { CodeHostType, Prisma, PrismaClient } from '@sourcebot/db';
import { WithRequired } from "./types.js"
import { marshalBool } from "./utils.js";
import { createLogger } from '@sourcebot/logger';
Expand DownExpand Up@@ -392,7 +392,7 @@ export const compileBitbucketConfig = async (

const repos = bitbucketRepos.map((repo) => {
const isServer = config.deploymentType === 'server';
const codeHostType= isServer ? 'bitbucket-server' : 'bitbucket-cloud'; // zoekt expects bitbucket-server
const codeHostType: CodeHostType = isServer ? 'bitbucketServer' : 'bitbucketCloud';
const displayName = isServer ? (repo as BitbucketServerRepository).name! : (repo as BitbucketCloudRepository).full_name!;
const externalId = isServer ? (repo as BitbucketServerRepository).id!.toString() : (repo as BitbucketCloudRepository).uuid!;
const isPublic = isServer ? (repo as BitbucketServerRepository).public : (repo as BitbucketCloudRepository).is_private === false;
Expand DownExpand Up@@ -425,7 +425,8 @@ export const compileBitbucketConfig = async (
},
metadata: {
gitConfig: {
'zoekt.web-url-type': codeHostType,
// zoekt expects bitbucket-server and bitbucket-cloud
'zoekt.web-url-type': codeHostType === 'bitbucketServer' ? 'bitbucket-server' : 'bitbucket-cloud',
'zoekt.web-url': webUrl,
'zoekt.name': repoName,
'zoekt.archived': marshalBool(isArchived),
Expand DownExpand Up@@ -507,7 +508,7 @@ export const compileGenericGitHostConfig_file = async (
const repoName = path.join(remoteUrl.host, remoteUrl.pathname.replace(/\.git$/, ''));

const repo: RepoData = {
external_codeHostType: 'generic-git-host',
external_codeHostType: 'genericGitHost',
external_codeHostUrl: remoteUrl.resource,
external_id: remoteUrl.toString(),
cloneUrl: `file://${repoPath}`,
Expand DownExpand Up@@ -571,7 +572,7 @@ export const compileGenericGitHostConfig_url = async (
const repoName = path.join(remoteUrl.host, remoteUrl.pathname.replace(/\.git$/, ''));

const repo: RepoData = {
external_codeHostType: 'generic-git-host',
external_codeHostType: 'genericGitHost',
external_codeHostUrl: remoteUrl.origin,
external_id: remoteUrl.toString(),
cloneUrl: remoteUrl.toString(),
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/utils.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,7 +59,7 @@ export const getRepoPath = (repo: Repo): { path: string, isReadOnly: boolean } =
// If we are dealing with a local repository, then use that as the path.
// Mark as read-only since we aren't guaranteed to have write access to the local filesystem.
const cloneUrl = new URL(repo.cloneUrl);
if (repo.external_codeHostType === 'generic-git-host' && cloneUrl.protocol === 'file:') {
if (repo.external_codeHostType === 'genericGitHost' && cloneUrl.protocol === 'file:') {
return {
path: cloneUrl.pathname,
isReadOnly: true,
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
/*
Migrates the `connectionType` column from text to a enum. The values in this field are known to
be one of the following: github, gitlab, gitea, gerrit, bitbucket, azuredevops, git.

This is occording to what we would expect to be in a valid config file for the schema version at commit 4899c9fbc755851af2ddcce99f4a4200f2faa4f6.
See: https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/schemas/src/v3/connection.type.ts#L3
*/
-- CreateEnum
CREATE TYPE "ConnectionType" AS ENUM ('github', 'gitlab', 'gitea', 'gerrit', 'bitbucket', 'azuredevops', 'git');

-- AlterTable - Convert existing column to enum type without dropping data
ALTER TABLE "Connection"
ALTER COLUMN "connectionType" TYPE "ConnectionType"
USING "connectionType"::text::"ConnectionType";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
/*
Migrates the `external_codeHostType` column from text to a enum. The values in this field are known to
be one of the following: github, gitlab, gitea, gerrit, bitbucket-server, bitbucket-cloud, generic-git-host, azuredevops.

This is occording to what we would expect to be in the database written as of commit 4899c9fbc755851af2ddcce99f4a4200f2faa4f6.
See:
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L57
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L135
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L208
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L291
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L407
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L510
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L574
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L642
*/
-- CreateEnum
CREATE TYPE "CodeHostType" AS ENUM ('github', 'gitlab', 'gitea', 'gerrit', 'bitbucket-server', 'bitbucket-cloud', 'generic-git-host', 'azuredevops');

-- AlterTable - Convert existing column to enum type without dropping data
ALTER TABLE "Repo"
ALTER COLUMN "external_codeHostType" TYPE "CodeHostType"
USING "external_codeHostType"::text::"CodeHostType";
31 changes: 29 additions & 2 deletions packages/db/prisma/schema.prisma
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,21 @@ enum ChatVisibility {
PUBLIC
}

/// @note: The @map annotation is required to maintain backwards compatibility
/// with the existing database.
/// @note: In the generated client, these mapped values will be in pascalCase.
/// This behaviour will change in prisma v7. See: https://github.com/prisma/prisma/issues/8446#issuecomment-3356119713
enum CodeHostType {
github
gitlab
gitea
gerrit
bitbucketServer @map("bitbucket-server")
bitbucketCloud @map("bitbucket-cloud")
genericGitHost @map("generic-git-host")
azuredevops
}

model Repo {
id Int @id @default(autoincrement())
name String /// Full repo name, including the vcs hostname (ex. github.com/sourcebot-dev/sourcebot)
Expand All@@ -53,7 +68,7 @@ model Repo {
indexedCommitHash String? /// The commit hash of the last indexed commit (on HEAD).

external_id String /// The id of the repo in the external service
external_codeHostType String /// The type of the external service (e.g., github, gitlab, etc.)
external_codeHostType CodeHostType /// The type of the external service (e.g., github, gitlab, etc.)
external_codeHostUrl String /// The base url of the external service (e.g., https://github.com)

org Org @relation(fields: [orgId], references: [id], onDelete: Cascade)
Expand DownExpand Up@@ -125,6 +140,18 @@ model SearchContext {
@@unique([name, orgId])
}

/// Matches the union of `type` fields in the schema.
/// @see: schemas/v3/connection.type.ts
enum ConnectionType {
github
gitlab
gitea
gerrit
bitbucket
azuredevops
git
}

model Connection {
id Int @id @default(autoincrement())
name String
Expand All@@ -135,7 +162,7 @@ model Connection {
repos RepoToConnection[]

// The type of connection (e.g., github, gitlab, etc.)
connectionType String
connectionType ConnectionType

syncJobs ConnectionSyncJob[]
/// When the connection was last synced successfully.
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ export const CodePreviewPanel = async ({ path, repoName, revisionName }: CodePre
branchDisplayName={revisionName}
/>

{(fileWebUrl && codeHostInfo) && (
{fileWebUrl && (

<a
href={fileWebUrl}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,9 +7,10 @@ import { Badge } from "@/components/ui/badge";
import { Card } from "@/components/ui/card";
import { CardContent } from "@/components/ui/card";
import { DemoExamples, DemoSearchExample, DemoSearchScope } from "@/types";
import { cn, CodeHostType, getCodeHostIcon } from "@/lib/utils";
import { cn, getCodeHostIcon } from "@/lib/utils";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { SearchScopeInfoCard } from "@/features/chat/components/chatBox/searchScopeInfoCard";
import { CodeHostType } from "@sourcebot/db";

interface DemoCards {
demoExamples: DemoExamples;
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/app/[domain]/components/configEditor.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,8 +12,8 @@ import { Separator } from "@/components/ui/separator";
import { Schema } from "ajv";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { CodeHostType } from "@/lib/utils";
import { useCodeMirrorTheme } from "@/hooks/useCodeMirrorTheme";
import { CodeHostType } from "@sourcebot/db";

export type QuickActionFn<T> = (previous: T) => T;
export type QuickAction<T> = {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,10 +9,11 @@ import { Input } from "@/components/ui/input";
import { Separator } from "@/components/ui/separator";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { useDomain } from "@/hooks/useDomain";
import { CodeHostType, isServiceError } from "@/lib/utils";
import { isServiceError } from "@/lib/utils";
import githubPatCreation from "@/public/github_pat_creation.png";
import gitlabPatCreation from "@/public/gitlab_pat_creation.png";
import giteaPatCreation from "@/public/gitea_pat_creation.png";
import { CodeHostType } from "@sourcebot/db";
import { zodResolver } from "@hookform/resolvers/zod";
import { Eye, EyeOff, Loader2 } from "lucide-react";
import Image from "next/image";
Expand DownExpand Up@@ -88,9 +89,9 @@ export const ImportSecretDialog = ({ open, onOpenChange, onSecretCreated, codeHo
return <GitHubPATCreationStep step={1} />;
case 'gitlab':
return <GitLabPATCreationStep step={1} />;
case 'bitbucket-cloud':
case 'bitbucketCloud':
return <BitbucketCloudPATCreationStep step={1} />;
case 'bitbucket-server':
case 'bitbucketServer':
return <BitbucketServerPATCreationStep step={1} />;
case 'gitea':
return <GiteaPATCreationStep step={1} />;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@ import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants";
import { RepositoryQuery } from "@/lib/types";
import { getCodeHostInfoForRepo, getShortenedNumberDisplayString } from "@/lib/utils";
import clsx from "clsx";
import { FileIcon, Loader2Icon, RefreshCwIcon } from "lucide-react";
import { Loader2Icon, RefreshCwIcon } from "lucide-react";
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/navigation";
Expand DownExpand Up@@ -90,23 +90,14 @@ const RepoItem = ({ repo }: { repo: RepositoryQuery }) => {
webUrl: repo.webUrl,
});

if (info) {
return {
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}
}

return {
repoIcon: <FileIcon className="w-4 h-4" />,
displayName: repo.repoName,
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}


}, [repo.repoName, repo.codeHostType, repo.repoDisplayName, repo.webUrl]);


Expand Down
22 changes: 9 additions & 13 deletions packages/web/src/app/[domain]/components/pathHeader.tsx
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
'use client';

import { cn, getCodeHostInfoForRepo } from "@/lib/utils";
import { LaptopIcon } from "@radix-ui/react-icons";
import Image from "next/image";
import { getBrowsePath } from "../browse/hooks/utils";
import { ChevronRight, MoreHorizontal } from "lucide-react";
Expand All@@ -17,6 +16,7 @@ import { VscodeFileIcon } from "@/app/components/vscodeFileIcon";
import { CopyIconButton } from "./copyIconButton";
import Link from "next/link";
import { useDomain } from "@/hooks/useDomain";
import { CodeHostType } from "@sourcebot/db";

interface FileHeaderProps {
path: string;
Expand All@@ -27,7 +27,7 @@ interface FileHeaderProps {
pathType?: 'blob' | 'tree';
repo: {
name: string;
codeHostType: string;
codeHostType: CodeHostType;
displayName?: string;
webUrl?: string;
},
Expand DownExpand Up@@ -202,17 +202,13 @@ export const PathHeader = ({
<div className="flex flex-row gap-2 items-center w-full overflow-hidden">
{isCodeHostIconVisible && (
<>
{info?.icon ? (
<a href={info.repoLink} target="_blank" rel="noopener noreferrer">
<Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>
</a>
) : (
<LaptopIcon className="w-4 h-4" />
)}
<a href={info.repoLink} target="_blank" rel="noopener noreferrer">
<Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>
</a>
</>
)}

Expand Down
20 changes: 6 additions & 14 deletions packages/web/src/app/[domain]/components/repositoryCarousel.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,6 @@ import {
import { captureEvent } from "@/hooks/useCaptureEvent";
import { RepositoryQuery } from "@/lib/types";
import { getCodeHostInfoForRepo } from "@/lib/utils";
import { FileIcon } from "@radix-ui/react-icons";
import clsx from "clsx";
import Autoscroll from "embla-carousel-auto-scroll";
import Image from "next/image";
Expand DownExpand Up@@ -121,20 +120,13 @@ const RepositoryBadge = ({
webUrl: repo.webUrl,
});

if (info) {
return {
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}
}

return {
repoIcon: <FileIcon className="w-4 h-4" />,
displayName: repo.repoName,
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
Comment thread
brendan-kellam marked this conversation as resolved.
}
})();

Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/app/[domain]/repos/[id]/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,7 +65,7 @@ export default async function RepoDetailPage({ params }: { params: Promise<{ id:
<h1 className="text-3xl font-semibold">{repo.displayName || repo.name}</h1>
<p className="text-muted-foreground mt-2">{repo.name}</p>
</div>
{(codeHostInfo && codeHostInfo.repoLink) && (
{codeHostInfo.repoLink && (
<Button variant="outline" asChild>
<Link href={codeHostInfo.repoLink} target="_blank" rel="noopener noreferrer" className="flex items-center">
<Image
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,13 +15,14 @@ import {
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { CodeHostType, getCodeHostBrowseAtBranchUrl } from "@/lib/utils"
import { getCodeHostBrowseAtBranchUrl } from "@/lib/utils"
import Link from "next/link"
import { CodeHostType } from "@sourcebot/db";

type RepoBranchesTableProps = {
indexRevisions: string[];
repoWebUrl: string | null;
repoCodeHostType: string;
repoCodeHostType: CodeHostType;
}

export const RepoBranchesTable = ({ indexRevisions, repoWebUrl, repoCodeHostType }: RepoBranchesTableProps) => {
Expand All@@ -39,7 +40,7 @@ export const RepoBranchesTable = ({ indexRevisions, repoWebUrl, repoCodeHostType

const branchUrl = getCodeHostBrowseAtBranchUrl({
webUrl: repoWebUrl,
codeHostType: repoCodeHostType as CodeHostType,
codeHostType: repoCodeHostType,
branchName: refName,
});

Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [ask sb] Fixed issue where reasoning tokens would appear in `text` content for openai compatible models. [#582](https://github.com/sourcebot-dev/sourcebot/pull/582)
- Fixed issue with GitHub app token tracking and refreshing. [#583](https://github.com/sourcebot-dev/sourcebot/pull/583)
- Fixed "The account is already associated with another user" errors with GitLab oauth provider. [#584](https://github.com/sourcebot-dev/sourcebot/pull/584)
- Fixed error when viewing a generic git connection in `/settings/connections`. [#588](https://github.com/sourcebot-dev/sourcebot/pull/588)

## [4.8.1] - 2025-10-29

Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/constants.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
import { CodeHostType } from "@sourcebot/db";
import { env } from "./env.js";
import path from "path";

export const SINGLE_TENANT_ORG_ID = 1;

export const PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES = [
export const PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES: CodeHostType[] = [
'github',
'gitlab',
];
Expand Down
11 changes: 6 additions & 5 deletions packages/backend/src/repoCompileUtils.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@ import { BitbucketRepository, getBitbucketReposFromConfig } from "./bitbucket.js
import { getAzureDevOpsReposFromConfig } from "./azuredevops.js";
import { SchemaRestRepository as BitbucketServerRepository } from "@coderabbitai/bitbucket/server/openapi";
import { SchemaRepository as BitbucketCloudRepository } from "@coderabbitai/bitbucket/cloud/openapi";
import { Prisma, PrismaClient } from '@sourcebot/db';
import { CodeHostType, Prisma, PrismaClient } from '@sourcebot/db';
import { WithRequired } from "./types.js"
import { marshalBool } from "./utils.js";
import { createLogger } from '@sourcebot/logger';
Expand DownExpand Up@@ -392,7 +392,7 @@ export const compileBitbucketConfig = async (

const repos = bitbucketRepos.map((repo) => {
const isServer = config.deploymentType === 'server';
const codeHostType= isServer ? 'bitbucket-server' : 'bitbucket-cloud'; // zoekt expects bitbucket-server
const codeHostType: CodeHostType = isServer ? 'bitbucketServer' : 'bitbucketCloud';
const displayName = isServer ? (repo as BitbucketServerRepository).name! : (repo as BitbucketCloudRepository).full_name!;
const externalId = isServer ? (repo as BitbucketServerRepository).id!.toString() : (repo as BitbucketCloudRepository).uuid!;
const isPublic = isServer ? (repo as BitbucketServerRepository).public : (repo as BitbucketCloudRepository).is_private === false;
Expand DownExpand Up@@ -425,7 +425,8 @@ export const compileBitbucketConfig = async (
},
metadata: {
gitConfig: {
'zoekt.web-url-type': codeHostType,
// zoekt expects bitbucket-server and bitbucket-cloud
'zoekt.web-url-type': codeHostType === 'bitbucketServer' ? 'bitbucket-server' : 'bitbucket-cloud',
'zoekt.web-url': webUrl,
'zoekt.name': repoName,
'zoekt.archived': marshalBool(isArchived),
Expand DownExpand Up@@ -507,7 +508,7 @@ export const compileGenericGitHostConfig_file = async (
const repoName = path.join(remoteUrl.host, remoteUrl.pathname.replace(/\.git$/, ''));

const repo: RepoData = {
external_codeHostType: 'generic-git-host',
external_codeHostType: 'genericGitHost',
external_codeHostUrl: remoteUrl.resource,
external_id: remoteUrl.toString(),
cloneUrl: `file://${repoPath}`,
Expand DownExpand Up@@ -571,7 +572,7 @@ export const compileGenericGitHostConfig_url = async (
const repoName = path.join(remoteUrl.host, remoteUrl.pathname.replace(/\.git$/, ''));

const repo: RepoData = {
external_codeHostType: 'generic-git-host',
external_codeHostType: 'genericGitHost',
external_codeHostUrl: remoteUrl.origin,
external_id: remoteUrl.toString(),
cloneUrl: remoteUrl.toString(),
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/utils.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,7 +59,7 @@ export const getRepoPath = (repo: Repo): { path: string, isReadOnly: boolean } =
// If we are dealing with a local repository, then use that as the path.
// Mark as read-only since we aren't guaranteed to have write access to the local filesystem.
const cloneUrl = new URL(repo.cloneUrl);
if (repo.external_codeHostType === 'generic-git-host' && cloneUrl.protocol === 'file:') {
if (repo.external_codeHostType === 'genericGitHost' && cloneUrl.protocol === 'file:') {
return {
path: cloneUrl.pathname,
isReadOnly: true,
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
/*
Migrates the `connectionType` column from text to a enum. The values in this field are known to
be one of the following: github, gitlab, gitea, gerrit, bitbucket, azuredevops, git.

This is occording to what we would expect to be in a valid config file for the schema version at commit 4899c9fbc755851af2ddcce99f4a4200f2faa4f6.
See: https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/schemas/src/v3/connection.type.ts#L3
*/
-- CreateEnum
CREATE TYPE "ConnectionType" AS ENUM ('github', 'gitlab', 'gitea', 'gerrit', 'bitbucket', 'azuredevops', 'git');

-- AlterTable - Convert existing column to enum type without dropping data
ALTER TABLE "Connection"
ALTER COLUMN "connectionType" TYPE "ConnectionType"
USING "connectionType"::text::"ConnectionType";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
/*
Migrates the `external_codeHostType` column from text to a enum. The values in this field are known to
be one of the following: github, gitlab, gitea, gerrit, bitbucket-server, bitbucket-cloud, generic-git-host, azuredevops.

This is occording to what we would expect to be in the database written as of commit 4899c9fbc755851af2ddcce99f4a4200f2faa4f6.
See:
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L57
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L135
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L208
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L291
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L407
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L510
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L574
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L642
*/
-- CreateEnum
CREATE TYPE "CodeHostType" AS ENUM ('github', 'gitlab', 'gitea', 'gerrit', 'bitbucket-server', 'bitbucket-cloud', 'generic-git-host', 'azuredevops');

-- AlterTable - Convert existing column to enum type without dropping data
ALTER TABLE "Repo"
ALTER COLUMN "external_codeHostType" TYPE "CodeHostType"
USING "external_codeHostType"::text::"CodeHostType";
31 changes: 29 additions & 2 deletions packages/db/prisma/schema.prisma
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,21 @@ enum ChatVisibility {
PUBLIC
}

/// @note: The @map annotation is required to maintain backwards compatibility
/// with the existing database.
/// @note: In the generated client, these mapped values will be in pascalCase.
/// This behaviour will change in prisma v7. See: https://github.com/prisma/prisma/issues/8446#issuecomment-3356119713
enum CodeHostType {
github
gitlab
gitea
gerrit
bitbucketServer @map("bitbucket-server")
bitbucketCloud @map("bitbucket-cloud")
genericGitHost @map("generic-git-host")
azuredevops
}

model Repo {
id Int @id @default(autoincrement())
name String /// Full repo name, including the vcs hostname (ex. github.com/sourcebot-dev/sourcebot)
Expand All@@ -53,7 +68,7 @@ model Repo {
indexedCommitHash String? /// The commit hash of the last indexed commit (on HEAD).

external_id String /// The id of the repo in the external service
external_codeHostType String /// The type of the external service (e.g., github, gitlab, etc.)
external_codeHostType CodeHostType /// The type of the external service (e.g., github, gitlab, etc.)
external_codeHostUrl String /// The base url of the external service (e.g., https://github.com)

org Org @relation(fields: [orgId], references: [id], onDelete: Cascade)
Expand DownExpand Up@@ -125,6 +140,18 @@ model SearchContext {
@@unique([name, orgId])
}

/// Matches the union of `type` fields in the schema.
/// @see: schemas/v3/connection.type.ts
enum ConnectionType {
github
gitlab
gitea
gerrit
bitbucket
azuredevops
git
}

model Connection {
id Int @id @default(autoincrement())
name String
Expand All@@ -135,7 +162,7 @@ model Connection {
repos RepoToConnection[]

// The type of connection (e.g., github, gitlab, etc.)
connectionType String
connectionType ConnectionType

syncJobs ConnectionSyncJob[]
/// When the connection was last synced successfully.
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ export const CodePreviewPanel = async ({ path, repoName, revisionName }: CodePre
branchDisplayName={revisionName}
/>

{(fileWebUrl && codeHostInfo) && (
{fileWebUrl && (

<a
href={fileWebUrl}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,9 +7,10 @@ import { Badge } from "@/components/ui/badge";
import { Card } from "@/components/ui/card";
import { CardContent } from "@/components/ui/card";
import { DemoExamples, DemoSearchExample, DemoSearchScope } from "@/types";
import { cn, CodeHostType, getCodeHostIcon } from "@/lib/utils";
import { cn, getCodeHostIcon } from "@/lib/utils";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { SearchScopeInfoCard } from "@/features/chat/components/chatBox/searchScopeInfoCard";
import { CodeHostType } from "@sourcebot/db";

interface DemoCards {
demoExamples: DemoExamples;
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/app/[domain]/components/configEditor.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,8 +12,8 @@ import { Separator } from "@/components/ui/separator";
import { Schema } from "ajv";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { CodeHostType } from "@/lib/utils";
import { useCodeMirrorTheme } from "@/hooks/useCodeMirrorTheme";
import { CodeHostType } from "@sourcebot/db";

export type QuickActionFn<T> = (previous: T) => T;
export type QuickAction<T> = {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,10 +9,11 @@ import { Input } from "@/components/ui/input";
import { Separator } from "@/components/ui/separator";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { useDomain } from "@/hooks/useDomain";
import { CodeHostType, isServiceError } from "@/lib/utils";
import { isServiceError } from "@/lib/utils";
import githubPatCreation from "@/public/github_pat_creation.png";
import gitlabPatCreation from "@/public/gitlab_pat_creation.png";
import giteaPatCreation from "@/public/gitea_pat_creation.png";
import { CodeHostType } from "@sourcebot/db";
import { zodResolver } from "@hookform/resolvers/zod";
import { Eye, EyeOff, Loader2 } from "lucide-react";
import Image from "next/image";
Expand DownExpand Up@@ -88,9 +89,9 @@ export const ImportSecretDialog = ({ open, onOpenChange, onSecretCreated, codeHo
return <GitHubPATCreationStep step={1} />;
case 'gitlab':
return <GitLabPATCreationStep step={1} />;
case 'bitbucket-cloud':
case 'bitbucketCloud':
return <BitbucketCloudPATCreationStep step={1} />;
case 'bitbucket-server':
case 'bitbucketServer':
return <BitbucketServerPATCreationStep step={1} />;
case 'gitea':
return <GiteaPATCreationStep step={1} />;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@ import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants";
import { RepositoryQuery } from "@/lib/types";
import { getCodeHostInfoForRepo, getShortenedNumberDisplayString } from "@/lib/utils";
import clsx from "clsx";
import { FileIcon, Loader2Icon, RefreshCwIcon } from "lucide-react";
import { Loader2Icon, RefreshCwIcon } from "lucide-react";
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/navigation";
Expand DownExpand Up@@ -90,23 +90,14 @@ const RepoItem = ({ repo }: { repo: RepositoryQuery }) => {
webUrl: repo.webUrl,
});

if (info) {
return {
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}
}

return {
repoIcon: <FileIcon className="w-4 h-4" />,
displayName: repo.repoName,
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}


}, [repo.repoName, repo.codeHostType, repo.repoDisplayName, repo.webUrl]);


Expand Down
22 changes: 9 additions & 13 deletions packages/web/src/app/[domain]/components/pathHeader.tsx
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
'use client';

import { cn, getCodeHostInfoForRepo } from "@/lib/utils";
import { LaptopIcon } from "@radix-ui/react-icons";
import Image from "next/image";
import { getBrowsePath } from "../browse/hooks/utils";
import { ChevronRight, MoreHorizontal } from "lucide-react";
Expand All@@ -17,6 +16,7 @@ import { VscodeFileIcon } from "@/app/components/vscodeFileIcon";
import { CopyIconButton } from "./copyIconButton";
import Link from "next/link";
import { useDomain } from "@/hooks/useDomain";
import { CodeHostType } from "@sourcebot/db";

interface FileHeaderProps {
path: string;
Expand All@@ -27,7 +27,7 @@ interface FileHeaderProps {
pathType?: 'blob' | 'tree';
repo: {
name: string;
codeHostType: string;
codeHostType: CodeHostType;
displayName?: string;
webUrl?: string;
},
Expand DownExpand Up@@ -202,17 +202,13 @@ export const PathHeader = ({
<div className="flex flex-row gap-2 items-center w-full overflow-hidden">
{isCodeHostIconVisible && (
<>
{info?.icon ? (
<a href={info.repoLink} target="_blank" rel="noopener noreferrer">
<Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>
</a>
) : (
<LaptopIcon className="w-4 h-4" />
)}
<a href={info.repoLink} target="_blank" rel="noopener noreferrer">
<Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>
</a>
</>
)}

Expand Down
20 changes: 6 additions & 14 deletions packages/web/src/app/[domain]/components/repositoryCarousel.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,6 @@ import {
import { captureEvent } from "@/hooks/useCaptureEvent";
import { RepositoryQuery } from "@/lib/types";
import { getCodeHostInfoForRepo } from "@/lib/utils";
import { FileIcon } from "@radix-ui/react-icons";
import clsx from "clsx";
import Autoscroll from "embla-carousel-auto-scroll";
import Image from "next/image";
Expand DownExpand Up@@ -121,20 +120,13 @@ const RepositoryBadge = ({
webUrl: repo.webUrl,
});

if (info) {
return {
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}
}

return {
repoIcon: <FileIcon className="w-4 h-4" />,
displayName: repo.repoName,
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
Comment thread
brendan-kellam marked this conversation as resolved.
}
})();

Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/app/[domain]/repos/[id]/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,7 +65,7 @@ export default async function RepoDetailPage({ params }: { params: Promise<{ id:
<h1 className="text-3xl font-semibold">{repo.displayName || repo.name}</h1>
<p className="text-muted-foreground mt-2">{repo.name}</p>
</div>
{(codeHostInfo && codeHostInfo.repoLink) && (
{codeHostInfo.repoLink && (
<Button variant="outline" asChild>
<Link href={codeHostInfo.repoLink} target="_blank" rel="noopener noreferrer" className="flex items-center">
<Image
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,13 +15,14 @@ import {
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { CodeHostType, getCodeHostBrowseAtBranchUrl } from "@/lib/utils"
import { getCodeHostBrowseAtBranchUrl } from "@/lib/utils"
import Link from "next/link"
import { CodeHostType } from "@sourcebot/db";

type RepoBranchesTableProps = {
indexRevisions: string[];
repoWebUrl: string | null;
repoCodeHostType: string;
repoCodeHostType: CodeHostType;
}

export const RepoBranchesTable = ({ indexRevisions, repoWebUrl, repoCodeHostType }: RepoBranchesTableProps) => {
Expand All@@ -39,7 +40,7 @@ export const RepoBranchesTable = ({ indexRevisions, repoWebUrl, repoCodeHostType

const branchUrl = getCodeHostBrowseAtBranchUrl({
webUrl: repoWebUrl,
codeHostType: repoCodeHostType as CodeHostType,
codeHostType: repoCodeHostType,
branchName: refName,
});

Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length \u003e 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [ask sb] Fixed issue where reasoning tokens would appear in `text` content for openai compatible models. [#582](https://github.com/sourcebot-dev/sourcebot/pull/582)
- Fixed issue with GitHub app token tracking and refreshing. [#583](https://github.com/sourcebot-dev/sourcebot/pull/583)
- Fixed "The account is already associated with another user" errors with GitLab oauth provider. [#584](https://github.com/sourcebot-dev/sourcebot/pull/584)
- Fixed error when viewing a generic git connection in `/settings/connections`. [#588](https://github.com/sourcebot-dev/sourcebot/pull/588)

## [4.8.1] - 2025-10-29

Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/constants.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
import { CodeHostType } from "@sourcebot/db";
import { env } from "./env.js";
import path from "path";

export const SINGLE_TENANT_ORG_ID = 1;

export const PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES = [
export const PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES: CodeHostType[] = [
'github',
'gitlab',
];
Expand Down
11 changes: 6 additions & 5 deletions packages/backend/src/repoCompileUtils.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@ import { BitbucketRepository, getBitbucketReposFromConfig } from "./bitbucket.js
import { getAzureDevOpsReposFromConfig } from "./azuredevops.js";
import { SchemaRestRepository as BitbucketServerRepository } from "@coderabbitai/bitbucket/server/openapi";
import { SchemaRepository as BitbucketCloudRepository } from "@coderabbitai/bitbucket/cloud/openapi";
import { Prisma, PrismaClient } from '@sourcebot/db';
import { CodeHostType, Prisma, PrismaClient } from '@sourcebot/db';
import { WithRequired } from "./types.js"
import { marshalBool } from "./utils.js";
import { createLogger } from '@sourcebot/logger';
Expand DownExpand Up@@ -392,7 +392,7 @@ export const compileBitbucketConfig = async (

const repos = bitbucketRepos.map((repo) => {
const isServer = config.deploymentType === 'server';
const codeHostType= isServer ? 'bitbucket-server' : 'bitbucket-cloud'; // zoekt expects bitbucket-server
const codeHostType: CodeHostType = isServer ? 'bitbucketServer' : 'bitbucketCloud';
const displayName = isServer ? (repo as BitbucketServerRepository).name! : (repo as BitbucketCloudRepository).full_name!;
const externalId = isServer ? (repo as BitbucketServerRepository).id!.toString() : (repo as BitbucketCloudRepository).uuid!;
const isPublic = isServer ? (repo as BitbucketServerRepository).public : (repo as BitbucketCloudRepository).is_private === false;
Expand DownExpand Up@@ -425,7 +425,8 @@ export const compileBitbucketConfig = async (
},
metadata: {
gitConfig: {
'zoekt.web-url-type': codeHostType,
// zoekt expects bitbucket-server and bitbucket-cloud
'zoekt.web-url-type': codeHostType === 'bitbucketServer' ? 'bitbucket-server' : 'bitbucket-cloud',
'zoekt.web-url': webUrl,
'zoekt.name': repoName,
'zoekt.archived': marshalBool(isArchived),
Expand DownExpand Up@@ -507,7 +508,7 @@ export const compileGenericGitHostConfig_file = async (
const repoName = path.join(remoteUrl.host, remoteUrl.pathname.replace(/\.git$/, ''));

const repo: RepoData = {
external_codeHostType: 'generic-git-host',
external_codeHostType: 'genericGitHost',
external_codeHostUrl: remoteUrl.resource,
external_id: remoteUrl.toString(),
cloneUrl: `file://${repoPath}`,
Expand DownExpand Up@@ -571,7 +572,7 @@ export const compileGenericGitHostConfig_url = async (
const repoName = path.join(remoteUrl.host, remoteUrl.pathname.replace(/\.git$/, ''));

const repo: RepoData = {
external_codeHostType: 'generic-git-host',
external_codeHostType: 'genericGitHost',
external_codeHostUrl: remoteUrl.origin,
external_id: remoteUrl.toString(),
cloneUrl: remoteUrl.toString(),
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/utils.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,7 +59,7 @@ export const getRepoPath = (repo: Repo): { path: string, isReadOnly: boolean } =
// If we are dealing with a local repository, then use that as the path.
// Mark as read-only since we aren't guaranteed to have write access to the local filesystem.
const cloneUrl = new URL(repo.cloneUrl);
if (repo.external_codeHostType === 'generic-git-host' && cloneUrl.protocol === 'file:') {
if (repo.external_codeHostType === 'genericGitHost' && cloneUrl.protocol === 'file:') {
return {
path: cloneUrl.pathname,
isReadOnly: true,
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
/*
Migrates the `connectionType` column from text to a enum. The values in this field are known to
be one of the following: github, gitlab, gitea, gerrit, bitbucket, azuredevops, git.

This is occording to what we would expect to be in a valid config file for the schema version at commit 4899c9fbc755851af2ddcce99f4a4200f2faa4f6.
See: https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/schemas/src/v3/connection.type.ts#L3
*/
-- CreateEnum
CREATE TYPE "ConnectionType" AS ENUM ('github', 'gitlab', 'gitea', 'gerrit', 'bitbucket', 'azuredevops', 'git');

-- AlterTable - Convert existing column to enum type without dropping data
ALTER TABLE "Connection"
ALTER COLUMN "connectionType" TYPE "ConnectionType"
USING "connectionType"::text::"ConnectionType";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
/*
Migrates the `external_codeHostType` column from text to a enum. The values in this field are known to
be one of the following: github, gitlab, gitea, gerrit, bitbucket-server, bitbucket-cloud, generic-git-host, azuredevops.

This is occording to what we would expect to be in the database written as of commit 4899c9fbc755851af2ddcce99f4a4200f2faa4f6.
See:
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L57
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L135
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L208
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L291
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L407
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L510
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L574
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L642
*/
-- CreateEnum
CREATE TYPE "CodeHostType" AS ENUM ('github', 'gitlab', 'gitea', 'gerrit', 'bitbucket-server', 'bitbucket-cloud', 'generic-git-host', 'azuredevops');

-- AlterTable - Convert existing column to enum type without dropping data
ALTER TABLE "Repo"
ALTER COLUMN "external_codeHostType" TYPE "CodeHostType"
USING "external_codeHostType"::text::"CodeHostType";
31 changes: 29 additions & 2 deletions packages/db/prisma/schema.prisma
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,21 @@ enum ChatVisibility {
PUBLIC
}

/// @note: The @map annotation is required to maintain backwards compatibility
/// with the existing database.
/// @note: In the generated client, these mapped values will be in pascalCase.
/// This behaviour will change in prisma v7. See: https://github.com/prisma/prisma/issues/8446#issuecomment-3356119713
enum CodeHostType {
github
gitlab
gitea
gerrit
bitbucketServer @map("bitbucket-server")
bitbucketCloud @map("bitbucket-cloud")
genericGitHost @map("generic-git-host")
azuredevops
}

model Repo {
id Int @id @default(autoincrement())
name String /// Full repo name, including the vcs hostname (ex. github.com/sourcebot-dev/sourcebot)
Expand All@@ -53,7 +68,7 @@ model Repo {
indexedCommitHash String? /// The commit hash of the last indexed commit (on HEAD).

external_id String /// The id of the repo in the external service
external_codeHostType String /// The type of the external service (e.g., github, gitlab, etc.)
external_codeHostType CodeHostType /// The type of the external service (e.g., github, gitlab, etc.)
external_codeHostUrl String /// The base url of the external service (e.g., https://github.com)

org Org @relation(fields: [orgId], references: [id], onDelete: Cascade)
Expand DownExpand Up@@ -125,6 +140,18 @@ model SearchContext {
@@unique([name, orgId])
}

/// Matches the union of `type` fields in the schema.
/// @see: schemas/v3/connection.type.ts
enum ConnectionType {
github
gitlab
gitea
gerrit
bitbucket
azuredevops
git
}

model Connection {
id Int @id @default(autoincrement())
name String
Expand All@@ -135,7 +162,7 @@ model Connection {
repos RepoToConnection[]

// The type of connection (e.g., github, gitlab, etc.)
connectionType String
connectionType ConnectionType

syncJobs ConnectionSyncJob[]
/// When the connection was last synced successfully.
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ export const CodePreviewPanel = async ({ path, repoName, revisionName }: CodePre
branchDisplayName={revisionName}
/>

{(fileWebUrl && codeHostInfo) && (
{fileWebUrl && (

<a
href={fileWebUrl}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,9 +7,10 @@ import { Badge } from "@/components/ui/badge";
import { Card } from "@/components/ui/card";
import { CardContent } from "@/components/ui/card";
import { DemoExamples, DemoSearchExample, DemoSearchScope } from "@/types";
import { cn, CodeHostType, getCodeHostIcon } from "@/lib/utils";
import { cn, getCodeHostIcon } from "@/lib/utils";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { SearchScopeInfoCard } from "@/features/chat/components/chatBox/searchScopeInfoCard";
import { CodeHostType } from "@sourcebot/db";

interface DemoCards {
demoExamples: DemoExamples;
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/app/[domain]/components/configEditor.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,8 +12,8 @@ import { Separator } from "@/components/ui/separator";
import { Schema } from "ajv";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { CodeHostType } from "@/lib/utils";
import { useCodeMirrorTheme } from "@/hooks/useCodeMirrorTheme";
import { CodeHostType } from "@sourcebot/db";

export type QuickActionFn<T> = (previous: T) => T;
export type QuickAction<T> = {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,10 +9,11 @@ import { Input } from "@/components/ui/input";
import { Separator } from "@/components/ui/separator";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { useDomain } from "@/hooks/useDomain";
import { CodeHostType, isServiceError } from "@/lib/utils";
import { isServiceError } from "@/lib/utils";
import githubPatCreation from "@/public/github_pat_creation.png";
import gitlabPatCreation from "@/public/gitlab_pat_creation.png";
import giteaPatCreation from "@/public/gitea_pat_creation.png";
import { CodeHostType } from "@sourcebot/db";
import { zodResolver } from "@hookform/resolvers/zod";
import { Eye, EyeOff, Loader2 } from "lucide-react";
import Image from "next/image";
Expand DownExpand Up@@ -88,9 +89,9 @@ export const ImportSecretDialog = ({ open, onOpenChange, onSecretCreated, codeHo
return <GitHubPATCreationStep step={1} />;
case 'gitlab':
return <GitLabPATCreationStep step={1} />;
case 'bitbucket-cloud':
case 'bitbucketCloud':
return <BitbucketCloudPATCreationStep step={1} />;
case 'bitbucket-server':
case 'bitbucketServer':
return <BitbucketServerPATCreationStep step={1} />;
case 'gitea':
return <GiteaPATCreationStep step={1} />;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@ import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants";
import { RepositoryQuery } from "@/lib/types";
import { getCodeHostInfoForRepo, getShortenedNumberDisplayString } from "@/lib/utils";
import clsx from "clsx";
import { FileIcon, Loader2Icon, RefreshCwIcon } from "lucide-react";
import { Loader2Icon, RefreshCwIcon } from "lucide-react";
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/navigation";
Expand DownExpand Up@@ -90,23 +90,14 @@ const RepoItem = ({ repo }: { repo: RepositoryQuery }) => {
webUrl: repo.webUrl,
});

if (info) {
return {
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}
}

return {
repoIcon: <FileIcon className="w-4 h-4" />,
displayName: repo.repoName,
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}


}, [repo.repoName, repo.codeHostType, repo.repoDisplayName, repo.webUrl]);


Expand Down
22 changes: 9 additions & 13 deletions packages/web/src/app/[domain]/components/pathHeader.tsx
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
'use client';

import { cn, getCodeHostInfoForRepo } from "@/lib/utils";
import { LaptopIcon } from "@radix-ui/react-icons";
import Image from "next/image";
import { getBrowsePath } from "../browse/hooks/utils";
import { ChevronRight, MoreHorizontal } from "lucide-react";
Expand All@@ -17,6 +16,7 @@ import { VscodeFileIcon } from "@/app/components/vscodeFileIcon";
import { CopyIconButton } from "./copyIconButton";
import Link from "next/link";
import { useDomain } from "@/hooks/useDomain";
import { CodeHostType } from "@sourcebot/db";

interface FileHeaderProps {
path: string;
Expand All@@ -27,7 +27,7 @@ interface FileHeaderProps {
pathType?: 'blob' | 'tree';
repo: {
name: string;
codeHostType: string;
codeHostType: CodeHostType;
displayName?: string;
webUrl?: string;
},
Expand DownExpand Up@@ -202,17 +202,13 @@ export const PathHeader = ({
<div className="flex flex-row gap-2 items-center w-full overflow-hidden">
{isCodeHostIconVisible && (
<>
{info?.icon ? (
<a href={info.repoLink} target="_blank" rel="noopener noreferrer">
<Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>
</a>
) : (
<LaptopIcon className="w-4 h-4" />
)}
<a href={info.repoLink} target="_blank" rel="noopener noreferrer">
<Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>
</a>
</>
)}

Expand Down
20 changes: 6 additions & 14 deletions packages/web/src/app/[domain]/components/repositoryCarousel.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,6 @@ import {
import { captureEvent } from "@/hooks/useCaptureEvent";
import { RepositoryQuery } from "@/lib/types";
import { getCodeHostInfoForRepo } from "@/lib/utils";
import { FileIcon } from "@radix-ui/react-icons";
import clsx from "clsx";
import Autoscroll from "embla-carousel-auto-scroll";
import Image from "next/image";
Expand DownExpand Up@@ -121,20 +120,13 @@ const RepositoryBadge = ({
webUrl: repo.webUrl,
});

if (info) {
return {
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}
}

return {
repoIcon: <FileIcon className="w-4 h-4" />,
displayName: repo.repoName,
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
Comment thread
brendan-kellam marked this conversation as resolved.
}
})();

Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/app/[domain]/repos/[id]/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,7 +65,7 @@ export default async function RepoDetailPage({ params }: { params: Promise<{ id:
<h1 className="text-3xl font-semibold">{repo.displayName || repo.name}</h1>
<p className="text-muted-foreground mt-2">{repo.name}</p>
</div>
{(codeHostInfo && codeHostInfo.repoLink) && (
{codeHostInfo.repoLink && (
<Button variant="outline" asChild>
<Link href={codeHostInfo.repoLink} target="_blank" rel="noopener noreferrer" className="flex items-center">
<Image
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,13 +15,14 @@ import {
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { CodeHostType, getCodeHostBrowseAtBranchUrl } from "@/lib/utils"
import { getCodeHostBrowseAtBranchUrl } from "@/lib/utils"
import Link from "next/link"
import { CodeHostType } from "@sourcebot/db";

type RepoBranchesTableProps = {
indexRevisions: string[];
repoWebUrl: string | null;
repoCodeHostType: string;
repoCodeHostType: CodeHostType;
}

export const RepoBranchesTable = ({ indexRevisions, repoWebUrl, repoCodeHostType }: RepoBranchesTableProps) => {
Expand All@@ -39,7 +40,7 @@ export const RepoBranchesTable = ({ indexRevisions, repoWebUrl, repoCodeHostType

const branchUrl = getCodeHostBrowseAtBranchUrl({
webUrl: repoWebUrl,
codeHostType: repoCodeHostType as CodeHostType,
codeHostType: repoCodeHostType,
branchName: refName,
});

Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [ask sb] Fixed issue where reasoning tokens would appear in `text` content for openai compatible models. [#582](https://github.com/sourcebot-dev/sourcebot/pull/582)
- Fixed issue with GitHub app token tracking and refreshing. [#583](https://github.com/sourcebot-dev/sourcebot/pull/583)
- Fixed "The account is already associated with another user" errors with GitLab oauth provider. [#584](https://github.com/sourcebot-dev/sourcebot/pull/584)
- Fixed error when viewing a generic git connection in `/settings/connections`. [#588](https://github.com/sourcebot-dev/sourcebot/pull/588)

## [4.8.1] - 2025-10-29

Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/constants.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
import { CodeHostType } from "@sourcebot/db";
import { env } from "./env.js";
import path from "path";

export const SINGLE_TENANT_ORG_ID = 1;

export const PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES = [
export const PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES: CodeHostType[] = [
'github',
'gitlab',
];
Expand Down
11 changes: 6 additions & 5 deletions packages/backend/src/repoCompileUtils.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@ import { BitbucketRepository, getBitbucketReposFromConfig } from "./bitbucket.js
import { getAzureDevOpsReposFromConfig } from "./azuredevops.js";
import { SchemaRestRepository as BitbucketServerRepository } from "@coderabbitai/bitbucket/server/openapi";
import { SchemaRepository as BitbucketCloudRepository } from "@coderabbitai/bitbucket/cloud/openapi";
import { Prisma, PrismaClient } from '@sourcebot/db';
import { CodeHostType, Prisma, PrismaClient } from '@sourcebot/db';
import { WithRequired } from "./types.js"
import { marshalBool } from "./utils.js";
import { createLogger } from '@sourcebot/logger';
Expand DownExpand Up@@ -392,7 +392,7 @@ export const compileBitbucketConfig = async (

const repos = bitbucketRepos.map((repo) => {
const isServer = config.deploymentType === 'server';
const codeHostType= isServer ? 'bitbucket-server' : 'bitbucket-cloud'; // zoekt expects bitbucket-server
const codeHostType: CodeHostType = isServer ? 'bitbucketServer' : 'bitbucketCloud';
const displayName = isServer ? (repo as BitbucketServerRepository).name! : (repo as BitbucketCloudRepository).full_name!;
const externalId = isServer ? (repo as BitbucketServerRepository).id!.toString() : (repo as BitbucketCloudRepository).uuid!;
const isPublic = isServer ? (repo as BitbucketServerRepository).public : (repo as BitbucketCloudRepository).is_private === false;
Expand DownExpand Up@@ -425,7 +425,8 @@ export const compileBitbucketConfig = async (
},
metadata: {
gitConfig: {
'zoekt.web-url-type': codeHostType,
// zoekt expects bitbucket-server and bitbucket-cloud
'zoekt.web-url-type': codeHostType === 'bitbucketServer' ? 'bitbucket-server' : 'bitbucket-cloud',
'zoekt.web-url': webUrl,
'zoekt.name': repoName,
'zoekt.archived': marshalBool(isArchived),
Expand DownExpand Up@@ -507,7 +508,7 @@ export const compileGenericGitHostConfig_file = async (
const repoName = path.join(remoteUrl.host, remoteUrl.pathname.replace(/\.git$/, ''));

const repo: RepoData = {
external_codeHostType: 'generic-git-host',
external_codeHostType: 'genericGitHost',
external_codeHostUrl: remoteUrl.resource,
external_id: remoteUrl.toString(),
cloneUrl: `file://${repoPath}`,
Expand DownExpand Up@@ -571,7 +572,7 @@ export const compileGenericGitHostConfig_url = async (
const repoName = path.join(remoteUrl.host, remoteUrl.pathname.replace(/\.git$/, ''));

const repo: RepoData = {
external_codeHostType: 'generic-git-host',
external_codeHostType: 'genericGitHost',
external_codeHostUrl: remoteUrl.origin,
external_id: remoteUrl.toString(),
cloneUrl: remoteUrl.toString(),
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/utils.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,7 +59,7 @@ export const getRepoPath = (repo: Repo): { path: string, isReadOnly: boolean } =
// If we are dealing with a local repository, then use that as the path.
// Mark as read-only since we aren't guaranteed to have write access to the local filesystem.
const cloneUrl = new URL(repo.cloneUrl);
if (repo.external_codeHostType === 'generic-git-host' && cloneUrl.protocol === 'file:') {
if (repo.external_codeHostType === 'genericGitHost' && cloneUrl.protocol === 'file:') {
return {
path: cloneUrl.pathname,
isReadOnly: true,
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
/*
Migrates the `connectionType` column from text to a enum. The values in this field are known to
be one of the following: github, gitlab, gitea, gerrit, bitbucket, azuredevops, git.

This is occording to what we would expect to be in a valid config file for the schema version at commit 4899c9fbc755851af2ddcce99f4a4200f2faa4f6.
See: https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/schemas/src/v3/connection.type.ts#L3
*/
-- CreateEnum
CREATE TYPE "ConnectionType" AS ENUM ('github', 'gitlab', 'gitea', 'gerrit', 'bitbucket', 'azuredevops', 'git');

-- AlterTable - Convert existing column to enum type without dropping data
ALTER TABLE "Connection"
ALTER COLUMN "connectionType" TYPE "ConnectionType"
USING "connectionType"::text::"ConnectionType";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
/*
Migrates the `external_codeHostType` column from text to a enum. The values in this field are known to
be one of the following: github, gitlab, gitea, gerrit, bitbucket-server, bitbucket-cloud, generic-git-host, azuredevops.

This is occording to what we would expect to be in the database written as of commit 4899c9fbc755851af2ddcce99f4a4200f2faa4f6.
See:
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L57
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L135
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L208
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L291
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L407
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L510
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L574
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L642
*/
-- CreateEnum
CREATE TYPE "CodeHostType" AS ENUM ('github', 'gitlab', 'gitea', 'gerrit', 'bitbucket-server', 'bitbucket-cloud', 'generic-git-host', 'azuredevops');

-- AlterTable - Convert existing column to enum type without dropping data
ALTER TABLE "Repo"
ALTER COLUMN "external_codeHostType" TYPE "CodeHostType"
USING "external_codeHostType"::text::"CodeHostType";
31 changes: 29 additions & 2 deletions packages/db/prisma/schema.prisma
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,21 @@ enum ChatVisibility {
PUBLIC
}

/// @note: The @map annotation is required to maintain backwards compatibility
/// with the existing database.
/// @note: In the generated client, these mapped values will be in pascalCase.
/// This behaviour will change in prisma v7. See: https://github.com/prisma/prisma/issues/8446#issuecomment-3356119713
enum CodeHostType {
github
gitlab
gitea
gerrit
bitbucketServer @map("bitbucket-server")
bitbucketCloud @map("bitbucket-cloud")
genericGitHost @map("generic-git-host")
azuredevops
}

model Repo {
id Int @id @default(autoincrement())
name String /// Full repo name, including the vcs hostname (ex. github.com/sourcebot-dev/sourcebot)
Expand All@@ -53,7 +68,7 @@ model Repo {
indexedCommitHash String? /// The commit hash of the last indexed commit (on HEAD).

external_id String /// The id of the repo in the external service
external_codeHostType String /// The type of the external service (e.g., github, gitlab, etc.)
external_codeHostType CodeHostType /// The type of the external service (e.g., github, gitlab, etc.)
external_codeHostUrl String /// The base url of the external service (e.g., https://github.com)

org Org @relation(fields: [orgId], references: [id], onDelete: Cascade)
Expand DownExpand Up@@ -125,6 +140,18 @@ model SearchContext {
@@unique([name, orgId])
}

/// Matches the union of `type` fields in the schema.
/// @see: schemas/v3/connection.type.ts
enum ConnectionType {
github
gitlab
gitea
gerrit
bitbucket
azuredevops
git
}

model Connection {
id Int @id @default(autoincrement())
name String
Expand All@@ -135,7 +162,7 @@ model Connection {
repos RepoToConnection[]

// The type of connection (e.g., github, gitlab, etc.)
connectionType String
connectionType ConnectionType

syncJobs ConnectionSyncJob[]
/// When the connection was last synced successfully.
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ export const CodePreviewPanel = async ({ path, repoName, revisionName }: CodePre
branchDisplayName={revisionName}
/>

{(fileWebUrl && codeHostInfo) && (
{fileWebUrl && (

<a
href={fileWebUrl}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,9 +7,10 @@ import { Badge } from "@/components/ui/badge";
import { Card } from "@/components/ui/card";
import { CardContent } from "@/components/ui/card";
import { DemoExamples, DemoSearchExample, DemoSearchScope } from "@/types";
import { cn, CodeHostType, getCodeHostIcon } from "@/lib/utils";
import { cn, getCodeHostIcon } from "@/lib/utils";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { SearchScopeInfoCard } from "@/features/chat/components/chatBox/searchScopeInfoCard";
import { CodeHostType } from "@sourcebot/db";

interface DemoCards {
demoExamples: DemoExamples;
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/app/[domain]/components/configEditor.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,8 +12,8 @@ import { Separator } from "@/components/ui/separator";
import { Schema } from "ajv";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { CodeHostType } from "@/lib/utils";
import { useCodeMirrorTheme } from "@/hooks/useCodeMirrorTheme";
import { CodeHostType } from "@sourcebot/db";

export type QuickActionFn<T> = (previous: T) => T;
export type QuickAction<T> = {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,10 +9,11 @@ import { Input } from "@/components/ui/input";
import { Separator } from "@/components/ui/separator";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { useDomain } from "@/hooks/useDomain";
import { CodeHostType, isServiceError } from "@/lib/utils";
import { isServiceError } from "@/lib/utils";
import githubPatCreation from "@/public/github_pat_creation.png";
import gitlabPatCreation from "@/public/gitlab_pat_creation.png";
import giteaPatCreation from "@/public/gitea_pat_creation.png";
import { CodeHostType } from "@sourcebot/db";
import { zodResolver } from "@hookform/resolvers/zod";
import { Eye, EyeOff, Loader2 } from "lucide-react";
import Image from "next/image";
Expand DownExpand Up@@ -88,9 +89,9 @@ export const ImportSecretDialog = ({ open, onOpenChange, onSecretCreated, codeHo
return <GitHubPATCreationStep step={1} />;
case 'gitlab':
return <GitLabPATCreationStep step={1} />;
case 'bitbucket-cloud':
case 'bitbucketCloud':
return <BitbucketCloudPATCreationStep step={1} />;
case 'bitbucket-server':
case 'bitbucketServer':
return <BitbucketServerPATCreationStep step={1} />;
case 'gitea':
return <GiteaPATCreationStep step={1} />;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@ import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants";
import { RepositoryQuery } from "@/lib/types";
import { getCodeHostInfoForRepo, getShortenedNumberDisplayString } from "@/lib/utils";
import clsx from "clsx";
import { FileIcon, Loader2Icon, RefreshCwIcon } from "lucide-react";
import { Loader2Icon, RefreshCwIcon } from "lucide-react";
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/navigation";
Expand DownExpand Up@@ -90,23 +90,14 @@ const RepoItem = ({ repo }: { repo: RepositoryQuery }) => {
webUrl: repo.webUrl,
});

if (info) {
return {
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}
}

return {
repoIcon: <FileIcon className="w-4 h-4" />,
displayName: repo.repoName,
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}


}, [repo.repoName, repo.codeHostType, repo.repoDisplayName, repo.webUrl]);


Expand Down
22 changes: 9 additions & 13 deletions packages/web/src/app/[domain]/components/pathHeader.tsx
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
'use client';

import { cn, getCodeHostInfoForRepo } from "@/lib/utils";
import { LaptopIcon } from "@radix-ui/react-icons";
import Image from "next/image";
import { getBrowsePath } from "../browse/hooks/utils";
import { ChevronRight, MoreHorizontal } from "lucide-react";
Expand All@@ -17,6 +16,7 @@ import { VscodeFileIcon } from "@/app/components/vscodeFileIcon";
import { CopyIconButton } from "./copyIconButton";
import Link from "next/link";
import { useDomain } from "@/hooks/useDomain";
import { CodeHostType } from "@sourcebot/db";

interface FileHeaderProps {
path: string;
Expand All@@ -27,7 +27,7 @@ interface FileHeaderProps {
pathType?: 'blob' | 'tree';
repo: {
name: string;
codeHostType: string;
codeHostType: CodeHostType;
displayName?: string;
webUrl?: string;
},
Expand DownExpand Up@@ -202,17 +202,13 @@ export const PathHeader = ({
<div className="flex flex-row gap-2 items-center w-full overflow-hidden">
{isCodeHostIconVisible && (
<>
{info?.icon ? (
<a href={info.repoLink} target="_blank" rel="noopener noreferrer">
<Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>
</a>
) : (
<LaptopIcon className="w-4 h-4" />
)}
<a href={info.repoLink} target="_blank" rel="noopener noreferrer">
<Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>
</a>
</>
)}

Expand Down
20 changes: 6 additions & 14 deletions packages/web/src/app/[domain]/components/repositoryCarousel.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,6 @@ import {
import { captureEvent } from "@/hooks/useCaptureEvent";
import { RepositoryQuery } from "@/lib/types";
import { getCodeHostInfoForRepo } from "@/lib/utils";
import { FileIcon } from "@radix-ui/react-icons";
import clsx from "clsx";
import Autoscroll from "embla-carousel-auto-scroll";
import Image from "next/image";
Expand DownExpand Up@@ -121,20 +120,13 @@ const RepositoryBadge = ({
webUrl: repo.webUrl,
});

if (info) {
return {
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}
}

return {
repoIcon: <FileIcon className="w-4 h-4" />,
displayName: repo.repoName,
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
Comment thread
brendan-kellam marked this conversation as resolved.
}
})();

Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/app/[domain]/repos/[id]/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,7 +65,7 @@ export default async function RepoDetailPage({ params }: { params: Promise<{ id:
<h1 className="text-3xl font-semibold">{repo.displayName || repo.name}</h1>
<p className="text-muted-foreground mt-2">{repo.name}</p>
</div>
{(codeHostInfo && codeHostInfo.repoLink) && (
{codeHostInfo.repoLink && (
<Button variant="outline" asChild>
<Link href={codeHostInfo.repoLink} target="_blank" rel="noopener noreferrer" className="flex items-center">
<Image
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,13 +15,14 @@ import {
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { CodeHostType, getCodeHostBrowseAtBranchUrl } from "@/lib/utils"
import { getCodeHostBrowseAtBranchUrl } from "@/lib/utils"
import Link from "next/link"
import { CodeHostType } from "@sourcebot/db";

type RepoBranchesTableProps = {
indexRevisions: string[];
repoWebUrl: string | null;
repoCodeHostType: string;
repoCodeHostType: CodeHostType;
}

export const RepoBranchesTable = ({ indexRevisions, repoWebUrl, repoCodeHostType }: RepoBranchesTableProps) => {
Expand All@@ -39,7 +40,7 @@ export const RepoBranchesTable = ({ indexRevisions, repoWebUrl, repoCodeHostType

const branchUrl = getCodeHostBrowseAtBranchUrl({
webUrl: repoWebUrl,
codeHostType: repoCodeHostType as CodeHostType,
codeHostType: repoCodeHostType,
branchName: refName,
});

Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [ask sb] Fixed issue where reasoning tokens would appear in `text` content for openai compatible models. [#582](https://github.com/sourcebot-dev/sourcebot/pull/582)
- Fixed issue with GitHub app token tracking and refreshing. [#583](https://github.com/sourcebot-dev/sourcebot/pull/583)
- Fixed "The account is already associated with another user" errors with GitLab oauth provider. [#584](https://github.com/sourcebot-dev/sourcebot/pull/584)
- Fixed error when viewing a generic git connection in `/settings/connections`. [#588](https://github.com/sourcebot-dev/sourcebot/pull/588)

## [4.8.1] - 2025-10-29

Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/constants.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
import { CodeHostType } from "@sourcebot/db";
import { env } from "./env.js";
import path from "path";

export const SINGLE_TENANT_ORG_ID = 1;

export const PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES = [
export const PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES: CodeHostType[] = [
'github',
'gitlab',
];
Expand Down
11 changes: 6 additions & 5 deletions packages/backend/src/repoCompileUtils.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@ import { BitbucketRepository, getBitbucketReposFromConfig } from "./bitbucket.js
import { getAzureDevOpsReposFromConfig } from "./azuredevops.js";
import { SchemaRestRepository as BitbucketServerRepository } from "@coderabbitai/bitbucket/server/openapi";
import { SchemaRepository as BitbucketCloudRepository } from "@coderabbitai/bitbucket/cloud/openapi";
import { Prisma, PrismaClient } from '@sourcebot/db';
import { CodeHostType, Prisma, PrismaClient } from '@sourcebot/db';
import { WithRequired } from "./types.js"
import { marshalBool } from "./utils.js";
import { createLogger } from '@sourcebot/logger';
Expand DownExpand Up@@ -392,7 +392,7 @@ export const compileBitbucketConfig = async (

const repos = bitbucketRepos.map((repo) => {
const isServer = config.deploymentType === 'server';
const codeHostType= isServer ? 'bitbucket-server' : 'bitbucket-cloud'; // zoekt expects bitbucket-server
const codeHostType: CodeHostType = isServer ? 'bitbucketServer' : 'bitbucketCloud';
const displayName = isServer ? (repo as BitbucketServerRepository).name! : (repo as BitbucketCloudRepository).full_name!;
const externalId = isServer ? (repo as BitbucketServerRepository).id!.toString() : (repo as BitbucketCloudRepository).uuid!;
const isPublic = isServer ? (repo as BitbucketServerRepository).public : (repo as BitbucketCloudRepository).is_private === false;
Expand DownExpand Up@@ -425,7 +425,8 @@ export const compileBitbucketConfig = async (
},
metadata: {
gitConfig: {
'zoekt.web-url-type': codeHostType,
// zoekt expects bitbucket-server and bitbucket-cloud
'zoekt.web-url-type': codeHostType === 'bitbucketServer' ? 'bitbucket-server' : 'bitbucket-cloud',
'zoekt.web-url': webUrl,
'zoekt.name': repoName,
'zoekt.archived': marshalBool(isArchived),
Expand DownExpand Up@@ -507,7 +508,7 @@ export const compileGenericGitHostConfig_file = async (
const repoName = path.join(remoteUrl.host, remoteUrl.pathname.replace(/\.git$/, ''));

const repo: RepoData = {
external_codeHostType: 'generic-git-host',
external_codeHostType: 'genericGitHost',
external_codeHostUrl: remoteUrl.resource,
external_id: remoteUrl.toString(),
cloneUrl: `file://${repoPath}`,
Expand DownExpand Up@@ -571,7 +572,7 @@ export const compileGenericGitHostConfig_url = async (
const repoName = path.join(remoteUrl.host, remoteUrl.pathname.replace(/\.git$/, ''));

const repo: RepoData = {
external_codeHostType: 'generic-git-host',
external_codeHostType: 'genericGitHost',
external_codeHostUrl: remoteUrl.origin,
external_id: remoteUrl.toString(),
cloneUrl: remoteUrl.toString(),
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/utils.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,7 +59,7 @@ export const getRepoPath = (repo: Repo): { path: string, isReadOnly: boolean } =
// If we are dealing with a local repository, then use that as the path.
// Mark as read-only since we aren't guaranteed to have write access to the local filesystem.
const cloneUrl = new URL(repo.cloneUrl);
if (repo.external_codeHostType === 'generic-git-host' && cloneUrl.protocol === 'file:') {
if (repo.external_codeHostType === 'genericGitHost' && cloneUrl.protocol === 'file:') {
return {
path: cloneUrl.pathname,
isReadOnly: true,
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
/*
Migrates the `connectionType` column from text to a enum. The values in this field are known to
be one of the following: github, gitlab, gitea, gerrit, bitbucket, azuredevops, git.

This is occording to what we would expect to be in a valid config file for the schema version at commit 4899c9fbc755851af2ddcce99f4a4200f2faa4f6.
See: https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/schemas/src/v3/connection.type.ts#L3
*/
-- CreateEnum
CREATE TYPE "ConnectionType" AS ENUM ('github', 'gitlab', 'gitea', 'gerrit', 'bitbucket', 'azuredevops', 'git');

-- AlterTable - Convert existing column to enum type without dropping data
ALTER TABLE "Connection"
ALTER COLUMN "connectionType" TYPE "ConnectionType"
USING "connectionType"::text::"ConnectionType";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
/*
Migrates the `external_codeHostType` column from text to a enum. The values in this field are known to
be one of the following: github, gitlab, gitea, gerrit, bitbucket-server, bitbucket-cloud, generic-git-host, azuredevops.

This is occording to what we would expect to be in the database written as of commit 4899c9fbc755851af2ddcce99f4a4200f2faa4f6.
See:
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L57
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L135
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L208
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L291
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L407
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L510
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L574
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L642
*/
-- CreateEnum
CREATE TYPE "CodeHostType" AS ENUM ('github', 'gitlab', 'gitea', 'gerrit', 'bitbucket-server', 'bitbucket-cloud', 'generic-git-host', 'azuredevops');

-- AlterTable - Convert existing column to enum type without dropping data
ALTER TABLE "Repo"
ALTER COLUMN "external_codeHostType" TYPE "CodeHostType"
USING "external_codeHostType"::text::"CodeHostType";
31 changes: 29 additions & 2 deletions packages/db/prisma/schema.prisma
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,21 @@ enum ChatVisibility {
PUBLIC
}

/// @note: The @map annotation is required to maintain backwards compatibility
/// with the existing database.
/// @note: In the generated client, these mapped values will be in pascalCase.
/// This behaviour will change in prisma v7. See: https://github.com/prisma/prisma/issues/8446#issuecomment-3356119713
enum CodeHostType {
github
gitlab
gitea
gerrit
bitbucketServer @map("bitbucket-server")
bitbucketCloud @map("bitbucket-cloud")
genericGitHost @map("generic-git-host")
azuredevops
}

model Repo {
id Int @id @default(autoincrement())
name String /// Full repo name, including the vcs hostname (ex. github.com/sourcebot-dev/sourcebot)
Expand All@@ -53,7 +68,7 @@ model Repo {
indexedCommitHash String? /// The commit hash of the last indexed commit (on HEAD).

external_id String /// The id of the repo in the external service
external_codeHostType String /// The type of the external service (e.g., github, gitlab, etc.)
external_codeHostType CodeHostType /// The type of the external service (e.g., github, gitlab, etc.)
external_codeHostUrl String /// The base url of the external service (e.g., https://github.com)

org Org @relation(fields: [orgId], references: [id], onDelete: Cascade)
Expand DownExpand Up@@ -125,6 +140,18 @@ model SearchContext {
@@unique([name, orgId])
}

/// Matches the union of `type` fields in the schema.
/// @see: schemas/v3/connection.type.ts
enum ConnectionType {
github
gitlab
gitea
gerrit
bitbucket
azuredevops
git
}

model Connection {
id Int @id @default(autoincrement())
name String
Expand All@@ -135,7 +162,7 @@ model Connection {
repos RepoToConnection[]

// The type of connection (e.g., github, gitlab, etc.)
connectionType String
connectionType ConnectionType

syncJobs ConnectionSyncJob[]
/// When the connection was last synced successfully.
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ export const CodePreviewPanel = async ({ path, repoName, revisionName }: CodePre
branchDisplayName={revisionName}
/>

{(fileWebUrl && codeHostInfo) && (
{fileWebUrl && (

<a
href={fileWebUrl}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,9 +7,10 @@ import { Badge } from "@/components/ui/badge";
import { Card } from "@/components/ui/card";
import { CardContent } from "@/components/ui/card";
import { DemoExamples, DemoSearchExample, DemoSearchScope } from "@/types";
import { cn, CodeHostType, getCodeHostIcon } from "@/lib/utils";
import { cn, getCodeHostIcon } from "@/lib/utils";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { SearchScopeInfoCard } from "@/features/chat/components/chatBox/searchScopeInfoCard";
import { CodeHostType } from "@sourcebot/db";

interface DemoCards {
demoExamples: DemoExamples;
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/app/[domain]/components/configEditor.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,8 +12,8 @@ import { Separator } from "@/components/ui/separator";
import { Schema } from "ajv";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { CodeHostType } from "@/lib/utils";
import { useCodeMirrorTheme } from "@/hooks/useCodeMirrorTheme";
import { CodeHostType } from "@sourcebot/db";

export type QuickActionFn<T> = (previous: T) => T;
export type QuickAction<T> = {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,10 +9,11 @@ import { Input } from "@/components/ui/input";
import { Separator } from "@/components/ui/separator";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { useDomain } from "@/hooks/useDomain";
import { CodeHostType, isServiceError } from "@/lib/utils";
import { isServiceError } from "@/lib/utils";
import githubPatCreation from "@/public/github_pat_creation.png";
import gitlabPatCreation from "@/public/gitlab_pat_creation.png";
import giteaPatCreation from "@/public/gitea_pat_creation.png";
import { CodeHostType } from "@sourcebot/db";
import { zodResolver } from "@hookform/resolvers/zod";
import { Eye, EyeOff, Loader2 } from "lucide-react";
import Image from "next/image";
Expand DownExpand Up@@ -88,9 +89,9 @@ export const ImportSecretDialog = ({ open, onOpenChange, onSecretCreated, codeHo
return <GitHubPATCreationStep step={1} />;
case 'gitlab':
return <GitLabPATCreationStep step={1} />;
case 'bitbucket-cloud':
case 'bitbucketCloud':
return <BitbucketCloudPATCreationStep step={1} />;
case 'bitbucket-server':
case 'bitbucketServer':
return <BitbucketServerPATCreationStep step={1} />;
case 'gitea':
return <GiteaPATCreationStep step={1} />;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@ import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants";
import { RepositoryQuery } from "@/lib/types";
import { getCodeHostInfoForRepo, getShortenedNumberDisplayString } from "@/lib/utils";
import clsx from "clsx";
import { FileIcon, Loader2Icon, RefreshCwIcon } from "lucide-react";
import { Loader2Icon, RefreshCwIcon } from "lucide-react";
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/navigation";
Expand DownExpand Up@@ -90,23 +90,14 @@ const RepoItem = ({ repo }: { repo: RepositoryQuery }) => {
webUrl: repo.webUrl,
});

if (info) {
return {
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}
}

return {
repoIcon: <FileIcon className="w-4 h-4" />,
displayName: repo.repoName,
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}


}, [repo.repoName, repo.codeHostType, repo.repoDisplayName, repo.webUrl]);


Expand Down
22 changes: 9 additions & 13 deletions packages/web/src/app/[domain]/components/pathHeader.tsx
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
'use client';

import { cn, getCodeHostInfoForRepo } from "@/lib/utils";
import { LaptopIcon } from "@radix-ui/react-icons";
import Image from "next/image";
import { getBrowsePath } from "../browse/hooks/utils";
import { ChevronRight, MoreHorizontal } from "lucide-react";
Expand All@@ -17,6 +16,7 @@ import { VscodeFileIcon } from "@/app/components/vscodeFileIcon";
import { CopyIconButton } from "./copyIconButton";
import Link from "next/link";
import { useDomain } from "@/hooks/useDomain";
import { CodeHostType } from "@sourcebot/db";

interface FileHeaderProps {
path: string;
Expand All@@ -27,7 +27,7 @@ interface FileHeaderProps {
pathType?: 'blob' | 'tree';
repo: {
name: string;
codeHostType: string;
codeHostType: CodeHostType;
displayName?: string;
webUrl?: string;
},
Expand DownExpand Up@@ -202,17 +202,13 @@ export const PathHeader = ({
<div className="flex flex-row gap-2 items-center w-full overflow-hidden">
{isCodeHostIconVisible && (
<>
{info?.icon ? (
<a href={info.repoLink} target="_blank" rel="noopener noreferrer">
<Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>
</a>
) : (
<LaptopIcon className="w-4 h-4" />
)}
<a href={info.repoLink} target="_blank" rel="noopener noreferrer">
<Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>
</a>
</>
)}

Expand Down
20 changes: 6 additions & 14 deletions packages/web/src/app/[domain]/components/repositoryCarousel.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,6 @@ import {
import { captureEvent } from "@/hooks/useCaptureEvent";
import { RepositoryQuery } from "@/lib/types";
import { getCodeHostInfoForRepo } from "@/lib/utils";
import { FileIcon } from "@radix-ui/react-icons";
import clsx from "clsx";
import Autoscroll from "embla-carousel-auto-scroll";
import Image from "next/image";
Expand DownExpand Up@@ -121,20 +120,13 @@ const RepositoryBadge = ({
webUrl: repo.webUrl,
});

if (info) {
return {
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}
}

return {
repoIcon: <FileIcon className="w-4 h-4" />,
displayName: repo.repoName,
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
Comment thread
brendan-kellam marked this conversation as resolved.
}
})();

Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/app/[domain]/repos/[id]/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,7 +65,7 @@ export default async function RepoDetailPage({ params }: { params: Promise<{ id:
<h1 className="text-3xl font-semibold">{repo.displayName || repo.name}</h1>
<p className="text-muted-foreground mt-2">{repo.name}</p>
</div>
{(codeHostInfo && codeHostInfo.repoLink) && (
{codeHostInfo.repoLink && (
<Button variant="outline" asChild>
<Link href={codeHostInfo.repoLink} target="_blank" rel="noopener noreferrer" className="flex items-center">
<Image
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,13 +15,14 @@ import {
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { CodeHostType, getCodeHostBrowseAtBranchUrl } from "@/lib/utils"
import { getCodeHostBrowseAtBranchUrl } from "@/lib/utils"
import Link from "next/link"
import { CodeHostType } from "@sourcebot/db";

type RepoBranchesTableProps = {
indexRevisions: string[];
repoWebUrl: string | null;
repoCodeHostType: string;
repoCodeHostType: CodeHostType;
}

export const RepoBranchesTable = ({ indexRevisions, repoWebUrl, repoCodeHostType }: RepoBranchesTableProps) => {
Expand All@@ -39,7 +40,7 @@ export const RepoBranchesTable = ({ indexRevisions, repoWebUrl, repoCodeHostType

const branchUrl = getCodeHostBrowseAtBranchUrl({
webUrl: repoWebUrl,
codeHostType: repoCodeHostType as CodeHostType,
codeHostType: repoCodeHostType,
branchName: refName,
});

Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [ask sb] Fixed issue where reasoning tokens would appear in `text` content for openai compatible models. [#582](https://github.com/sourcebot-dev/sourcebot/pull/582)
- Fixed issue with GitHub app token tracking and refreshing. [#583](https://github.com/sourcebot-dev/sourcebot/pull/583)
- Fixed "The account is already associated with another user" errors with GitLab oauth provider. [#584](https://github.com/sourcebot-dev/sourcebot/pull/584)
- Fixed error when viewing a generic git connection in `/settings/connections`. [#588](https://github.com/sourcebot-dev/sourcebot/pull/588)

## [4.8.1] - 2025-10-29

Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/constants.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
import { CodeHostType } from "@sourcebot/db";
import { env } from "./env.js";
import path from "path";

export const SINGLE_TENANT_ORG_ID = 1;

export const PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES = [
export const PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES: CodeHostType[] = [
'github',
'gitlab',
];
Expand Down
11 changes: 6 additions & 5 deletions packages/backend/src/repoCompileUtils.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@ import { BitbucketRepository, getBitbucketReposFromConfig } from "./bitbucket.js
import { getAzureDevOpsReposFromConfig } from "./azuredevops.js";
import { SchemaRestRepository as BitbucketServerRepository } from "@coderabbitai/bitbucket/server/openapi";
import { SchemaRepository as BitbucketCloudRepository } from "@coderabbitai/bitbucket/cloud/openapi";
import { Prisma, PrismaClient } from '@sourcebot/db';
import { CodeHostType, Prisma, PrismaClient } from '@sourcebot/db';
import { WithRequired } from "./types.js"
import { marshalBool } from "./utils.js";
import { createLogger } from '@sourcebot/logger';
Expand DownExpand Up@@ -392,7 +392,7 @@ export const compileBitbucketConfig = async (

const repos = bitbucketRepos.map((repo) => {
const isServer = config.deploymentType === 'server';
const codeHostType= isServer ? 'bitbucket-server' : 'bitbucket-cloud'; // zoekt expects bitbucket-server
const codeHostType: CodeHostType = isServer ? 'bitbucketServer' : 'bitbucketCloud';
const displayName = isServer ? (repo as BitbucketServerRepository).name! : (repo as BitbucketCloudRepository).full_name!;
const externalId = isServer ? (repo as BitbucketServerRepository).id!.toString() : (repo as BitbucketCloudRepository).uuid!;
const isPublic = isServer ? (repo as BitbucketServerRepository).public : (repo as BitbucketCloudRepository).is_private === false;
Expand DownExpand Up@@ -425,7 +425,8 @@ export const compileBitbucketConfig = async (
},
metadata: {
gitConfig: {
'zoekt.web-url-type': codeHostType,
// zoekt expects bitbucket-server and bitbucket-cloud
'zoekt.web-url-type': codeHostType === 'bitbucketServer' ? 'bitbucket-server' : 'bitbucket-cloud',
'zoekt.web-url': webUrl,
'zoekt.name': repoName,
'zoekt.archived': marshalBool(isArchived),
Expand DownExpand Up@@ -507,7 +508,7 @@ export const compileGenericGitHostConfig_file = async (
const repoName = path.join(remoteUrl.host, remoteUrl.pathname.replace(/\.git$/, ''));

const repo: RepoData = {
external_codeHostType: 'generic-git-host',
external_codeHostType: 'genericGitHost',
external_codeHostUrl: remoteUrl.resource,
external_id: remoteUrl.toString(),
cloneUrl: `file://${repoPath}`,
Expand DownExpand Up@@ -571,7 +572,7 @@ export const compileGenericGitHostConfig_url = async (
const repoName = path.join(remoteUrl.host, remoteUrl.pathname.replace(/\.git$/, ''));

const repo: RepoData = {
external_codeHostType: 'generic-git-host',
external_codeHostType: 'genericGitHost',
external_codeHostUrl: remoteUrl.origin,
external_id: remoteUrl.toString(),
cloneUrl: remoteUrl.toString(),
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/utils.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,7 +59,7 @@ export const getRepoPath = (repo: Repo): { path: string, isReadOnly: boolean } =
// If we are dealing with a local repository, then use that as the path.
// Mark as read-only since we aren't guaranteed to have write access to the local filesystem.
const cloneUrl = new URL(repo.cloneUrl);
if (repo.external_codeHostType === 'generic-git-host' && cloneUrl.protocol === 'file:') {
if (repo.external_codeHostType === 'genericGitHost' && cloneUrl.protocol === 'file:') {
return {
path: cloneUrl.pathname,
isReadOnly: true,
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
/*
Migrates the `connectionType` column from text to a enum. The values in this field are known to
be one of the following: github, gitlab, gitea, gerrit, bitbucket, azuredevops, git.

This is occording to what we would expect to be in a valid config file for the schema version at commit 4899c9fbc755851af2ddcce99f4a4200f2faa4f6.
See: https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/schemas/src/v3/connection.type.ts#L3
*/
-- CreateEnum
CREATE TYPE "ConnectionType" AS ENUM ('github', 'gitlab', 'gitea', 'gerrit', 'bitbucket', 'azuredevops', 'git');

-- AlterTable - Convert existing column to enum type without dropping data
ALTER TABLE "Connection"
ALTER COLUMN "connectionType" TYPE "ConnectionType"
USING "connectionType"::text::"ConnectionType";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
/*
Migrates the `external_codeHostType` column from text to a enum. The values in this field are known to
be one of the following: github, gitlab, gitea, gerrit, bitbucket-server, bitbucket-cloud, generic-git-host, azuredevops.

This is occording to what we would expect to be in the database written as of commit 4899c9fbc755851af2ddcce99f4a4200f2faa4f6.
See:
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L57
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L135
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L208
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L291
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L407
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L510
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L574
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L642
*/
-- CreateEnum
CREATE TYPE "CodeHostType" AS ENUM ('github', 'gitlab', 'gitea', 'gerrit', 'bitbucket-server', 'bitbucket-cloud', 'generic-git-host', 'azuredevops');

-- AlterTable - Convert existing column to enum type without dropping data
ALTER TABLE "Repo"
ALTER COLUMN "external_codeHostType" TYPE "CodeHostType"
USING "external_codeHostType"::text::"CodeHostType";
31 changes: 29 additions & 2 deletions packages/db/prisma/schema.prisma
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,21 @@ enum ChatVisibility {
PUBLIC
}

/// @note: The @map annotation is required to maintain backwards compatibility
/// with the existing database.
/// @note: In the generated client, these mapped values will be in pascalCase.
/// This behaviour will change in prisma v7. See: https://github.com/prisma/prisma/issues/8446#issuecomment-3356119713
enum CodeHostType {
github
gitlab
gitea
gerrit
bitbucketServer @map("bitbucket-server")
bitbucketCloud @map("bitbucket-cloud")
genericGitHost @map("generic-git-host")
azuredevops
}

model Repo {
id Int @id @default(autoincrement())
name String /// Full repo name, including the vcs hostname (ex. github.com/sourcebot-dev/sourcebot)
Expand All@@ -53,7 +68,7 @@ model Repo {
indexedCommitHash String? /// The commit hash of the last indexed commit (on HEAD).

external_id String /// The id of the repo in the external service
external_codeHostType String /// The type of the external service (e.g., github, gitlab, etc.)
external_codeHostType CodeHostType /// The type of the external service (e.g., github, gitlab, etc.)
external_codeHostUrl String /// The base url of the external service (e.g., https://github.com)

org Org @relation(fields: [orgId], references: [id], onDelete: Cascade)
Expand DownExpand Up@@ -125,6 +140,18 @@ model SearchContext {
@@unique([name, orgId])
}

/// Matches the union of `type` fields in the schema.
/// @see: schemas/v3/connection.type.ts
enum ConnectionType {
github
gitlab
gitea
gerrit
bitbucket
azuredevops
git
}

model Connection {
id Int @id @default(autoincrement())
name String
Expand All@@ -135,7 +162,7 @@ model Connection {
repos RepoToConnection[]

// The type of connection (e.g., github, gitlab, etc.)
connectionType String
connectionType ConnectionType

syncJobs ConnectionSyncJob[]
/// When the connection was last synced successfully.
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ export const CodePreviewPanel = async ({ path, repoName, revisionName }: CodePre
branchDisplayName={revisionName}
/>

{(fileWebUrl && codeHostInfo) && (
{fileWebUrl && (

<a
href={fileWebUrl}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,9 +7,10 @@ import { Badge } from "@/components/ui/badge";
import { Card } from "@/components/ui/card";
import { CardContent } from "@/components/ui/card";
import { DemoExamples, DemoSearchExample, DemoSearchScope } from "@/types";
import { cn, CodeHostType, getCodeHostIcon } from "@/lib/utils";
import { cn, getCodeHostIcon } from "@/lib/utils";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { SearchScopeInfoCard } from "@/features/chat/components/chatBox/searchScopeInfoCard";
import { CodeHostType } from "@sourcebot/db";

interface DemoCards {
demoExamples: DemoExamples;
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/app/[domain]/components/configEditor.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,8 +12,8 @@ import { Separator } from "@/components/ui/separator";
import { Schema } from "ajv";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { CodeHostType } from "@/lib/utils";
import { useCodeMirrorTheme } from "@/hooks/useCodeMirrorTheme";
import { CodeHostType } from "@sourcebot/db";

export type QuickActionFn<T> = (previous: T) => T;
export type QuickAction<T> = {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,10 +9,11 @@ import { Input } from "@/components/ui/input";
import { Separator } from "@/components/ui/separator";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { useDomain } from "@/hooks/useDomain";
import { CodeHostType, isServiceError } from "@/lib/utils";
import { isServiceError } from "@/lib/utils";
import githubPatCreation from "@/public/github_pat_creation.png";
import gitlabPatCreation from "@/public/gitlab_pat_creation.png";
import giteaPatCreation from "@/public/gitea_pat_creation.png";
import { CodeHostType } from "@sourcebot/db";
import { zodResolver } from "@hookform/resolvers/zod";
import { Eye, EyeOff, Loader2 } from "lucide-react";
import Image from "next/image";
Expand DownExpand Up@@ -88,9 +89,9 @@ export const ImportSecretDialog = ({ open, onOpenChange, onSecretCreated, codeHo
return <GitHubPATCreationStep step={1} />;
case 'gitlab':
return <GitLabPATCreationStep step={1} />;
case 'bitbucket-cloud':
case 'bitbucketCloud':
return <BitbucketCloudPATCreationStep step={1} />;
case 'bitbucket-server':
case 'bitbucketServer':
return <BitbucketServerPATCreationStep step={1} />;
case 'gitea':
return <GiteaPATCreationStep step={1} />;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@ import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants";
import { RepositoryQuery } from "@/lib/types";
import { getCodeHostInfoForRepo, getShortenedNumberDisplayString } from "@/lib/utils";
import clsx from "clsx";
import { FileIcon, Loader2Icon, RefreshCwIcon } from "lucide-react";
import { Loader2Icon, RefreshCwIcon } from "lucide-react";
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/navigation";
Expand DownExpand Up@@ -90,23 +90,14 @@ const RepoItem = ({ repo }: { repo: RepositoryQuery }) => {
webUrl: repo.webUrl,
});

if (info) {
return {
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}
}

return {
repoIcon: <FileIcon className="w-4 h-4" />,
displayName: repo.repoName,
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}


}, [repo.repoName, repo.codeHostType, repo.repoDisplayName, repo.webUrl]);


Expand Down
22 changes: 9 additions & 13 deletions packages/web/src/app/[domain]/components/pathHeader.tsx
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
'use client';

import { cn, getCodeHostInfoForRepo } from "@/lib/utils";
import { LaptopIcon } from "@radix-ui/react-icons";
import Image from "next/image";
import { getBrowsePath } from "../browse/hooks/utils";
import { ChevronRight, MoreHorizontal } from "lucide-react";
Expand All@@ -17,6 +16,7 @@ import { VscodeFileIcon } from "@/app/components/vscodeFileIcon";
import { CopyIconButton } from "./copyIconButton";
import Link from "next/link";
import { useDomain } from "@/hooks/useDomain";
import { CodeHostType } from "@sourcebot/db";

interface FileHeaderProps {
path: string;
Expand All@@ -27,7 +27,7 @@ interface FileHeaderProps {
pathType?: 'blob' | 'tree';
repo: {
name: string;
codeHostType: string;
codeHostType: CodeHostType;
displayName?: string;
webUrl?: string;
},
Expand DownExpand Up@@ -202,17 +202,13 @@ export const PathHeader = ({
<div className="flex flex-row gap-2 items-center w-full overflow-hidden">
{isCodeHostIconVisible && (
<>
{info?.icon ? (
<a href={info.repoLink} target="_blank" rel="noopener noreferrer">
<Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>
</a>
) : (
<LaptopIcon className="w-4 h-4" />
)}
<a href={info.repoLink} target="_blank" rel="noopener noreferrer">
<Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>
</a>
</>
)}

Expand Down
20 changes: 6 additions & 14 deletions packages/web/src/app/[domain]/components/repositoryCarousel.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,6 @@ import {
import { captureEvent } from "@/hooks/useCaptureEvent";
import { RepositoryQuery } from "@/lib/types";
import { getCodeHostInfoForRepo } from "@/lib/utils";
import { FileIcon } from "@radix-ui/react-icons";
import clsx from "clsx";
import Autoscroll from "embla-carousel-auto-scroll";
import Image from "next/image";
Expand DownExpand Up@@ -121,20 +120,13 @@ const RepositoryBadge = ({
webUrl: repo.webUrl,
});

if (info) {
return {
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}
}

return {
repoIcon: <FileIcon className="w-4 h-4" />,
displayName: repo.repoName,
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
Comment thread
brendan-kellam marked this conversation as resolved.
}
})();

Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/app/[domain]/repos/[id]/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,7 +65,7 @@ export default async function RepoDetailPage({ params }: { params: Promise<{ id:
<h1 className="text-3xl font-semibold">{repo.displayName || repo.name}</h1>
<p className="text-muted-foreground mt-2">{repo.name}</p>
</div>
{(codeHostInfo && codeHostInfo.repoLink) && (
{codeHostInfo.repoLink && (
<Button variant="outline" asChild>
<Link href={codeHostInfo.repoLink} target="_blank" rel="noopener noreferrer" className="flex items-center">
<Image
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,13 +15,14 @@ import {
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { CodeHostType, getCodeHostBrowseAtBranchUrl } from "@/lib/utils"
import { getCodeHostBrowseAtBranchUrl } from "@/lib/utils"
import Link from "next/link"
import { CodeHostType } from "@sourcebot/db";

type RepoBranchesTableProps = {
indexRevisions: string[];
repoWebUrl: string | null;
repoCodeHostType: string;
repoCodeHostType: CodeHostType;
}

export const RepoBranchesTable = ({ indexRevisions, repoWebUrl, repoCodeHostType }: RepoBranchesTableProps) => {
Expand All@@ -39,7 +40,7 @@ export const RepoBranchesTable = ({ indexRevisions, repoWebUrl, repoCodeHostType

const branchUrl = getCodeHostBrowseAtBranchUrl({
webUrl: repoWebUrl,
codeHostType: repoCodeHostType as CodeHostType,
codeHostType: repoCodeHostType,
branchName: refName,
});

Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [ask sb] Fixed issue where reasoning tokens would appear in `text` content for openai compatible models. [#582](https://github.com/sourcebot-dev/sourcebot/pull/582)
- Fixed issue with GitHub app token tracking and refreshing. [#583](https://github.com/sourcebot-dev/sourcebot/pull/583)
- Fixed "The account is already associated with another user" errors with GitLab oauth provider. [#584](https://github.com/sourcebot-dev/sourcebot/pull/584)
- Fixed error when viewing a generic git connection in `/settings/connections`. [#588](https://github.com/sourcebot-dev/sourcebot/pull/588)

## [4.8.1] - 2025-10-29

Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/constants.ts
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
import { CodeHostType } from "@sourcebot/db";
import { env } from "./env.js";
import path from "path";

export const SINGLE_TENANT_ORG_ID = 1;

export const PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES = [
export const PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES: CodeHostType[] = [
'github',
'gitlab',
];
Expand Down
11 changes: 6 additions & 5 deletions packages/backend/src/repoCompileUtils.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@ import { BitbucketRepository, getBitbucketReposFromConfig } from "./bitbucket.js
import { getAzureDevOpsReposFromConfig } from "./azuredevops.js";
import { SchemaRestRepository as BitbucketServerRepository } from "@coderabbitai/bitbucket/server/openapi";
import { SchemaRepository as BitbucketCloudRepository } from "@coderabbitai/bitbucket/cloud/openapi";
import { Prisma, PrismaClient } from '@sourcebot/db';
import { CodeHostType, Prisma, PrismaClient } from '@sourcebot/db';
import { WithRequired } from "./types.js"
import { marshalBool } from "./utils.js";
import { createLogger } from '@sourcebot/logger';
Expand DownExpand Up@@ -392,7 +392,7 @@ export const compileBitbucketConfig = async (

const repos = bitbucketRepos.map((repo) => {
const isServer = config.deploymentType === 'server';
const codeHostType= isServer ? 'bitbucket-server' : 'bitbucket-cloud'; // zoekt expects bitbucket-server
const codeHostType: CodeHostType = isServer ? 'bitbucketServer' : 'bitbucketCloud';
const displayName = isServer ? (repo as BitbucketServerRepository).name! : (repo as BitbucketCloudRepository).full_name!;
const externalId = isServer ? (repo as BitbucketServerRepository).id!.toString() : (repo as BitbucketCloudRepository).uuid!;
const isPublic = isServer ? (repo as BitbucketServerRepository).public : (repo as BitbucketCloudRepository).is_private === false;
Expand DownExpand Up@@ -425,7 +425,8 @@ export const compileBitbucketConfig = async (
},
metadata: {
gitConfig: {
'zoekt.web-url-type': codeHostType,
// zoekt expects bitbucket-server and bitbucket-cloud
'zoekt.web-url-type': codeHostType === 'bitbucketServer' ? 'bitbucket-server' : 'bitbucket-cloud',
'zoekt.web-url': webUrl,
'zoekt.name': repoName,
'zoekt.archived': marshalBool(isArchived),
Expand DownExpand Up@@ -507,7 +508,7 @@ export const compileGenericGitHostConfig_file = async (
const repoName = path.join(remoteUrl.host, remoteUrl.pathname.replace(/\.git$/, ''));

const repo: RepoData = {
external_codeHostType: 'generic-git-host',
external_codeHostType: 'genericGitHost',
external_codeHostUrl: remoteUrl.resource,
external_id: remoteUrl.toString(),
cloneUrl: `file://${repoPath}`,
Expand DownExpand Up@@ -571,7 +572,7 @@ export const compileGenericGitHostConfig_url = async (
const repoName = path.join(remoteUrl.host, remoteUrl.pathname.replace(/\.git$/, ''));

const repo: RepoData = {
external_codeHostType: 'generic-git-host',
external_codeHostType: 'genericGitHost',
external_codeHostUrl: remoteUrl.origin,
external_id: remoteUrl.toString(),
cloneUrl: remoteUrl.toString(),
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/utils.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,7 +59,7 @@ export const getRepoPath = (repo: Repo): { path: string, isReadOnly: boolean } =
// If we are dealing with a local repository, then use that as the path.
// Mark as read-only since we aren't guaranteed to have write access to the local filesystem.
const cloneUrl = new URL(repo.cloneUrl);
if (repo.external_codeHostType === 'generic-git-host' && cloneUrl.protocol === 'file:') {
if (repo.external_codeHostType === 'genericGitHost' && cloneUrl.protocol === 'file:') {
return {
path: cloneUrl.pathname,
isReadOnly: true,
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
/*
Migrates the `connectionType` column from text to a enum. The values in this field are known to
be one of the following: github, gitlab, gitea, gerrit, bitbucket, azuredevops, git.

This is occording to what we would expect to be in a valid config file for the schema version at commit 4899c9fbc755851af2ddcce99f4a4200f2faa4f6.
See: https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/schemas/src/v3/connection.type.ts#L3
*/
-- CreateEnum
CREATE TYPE "ConnectionType" AS ENUM ('github', 'gitlab', 'gitea', 'gerrit', 'bitbucket', 'azuredevops', 'git');

-- AlterTable - Convert existing column to enum type without dropping data
ALTER TABLE "Connection"
ALTER COLUMN "connectionType" TYPE "ConnectionType"
USING "connectionType"::text::"ConnectionType";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
/*
Migrates the `external_codeHostType` column from text to a enum. The values in this field are known to
be one of the following: github, gitlab, gitea, gerrit, bitbucket-server, bitbucket-cloud, generic-git-host, azuredevops.

This is occording to what we would expect to be in the database written as of commit 4899c9fbc755851af2ddcce99f4a4200f2faa4f6.
See:
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L57
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L135
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L208
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L291
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L407
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L510
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L574
- https://github.com/sourcebot-dev/sourcebot/blob/4899c9fbc755851af2ddcce99f4a4200f2faa4f6/packages/backend/src/repoCompileUtils.ts#L642
*/
-- CreateEnum
CREATE TYPE "CodeHostType" AS ENUM ('github', 'gitlab', 'gitea', 'gerrit', 'bitbucket-server', 'bitbucket-cloud', 'generic-git-host', 'azuredevops');

-- AlterTable - Convert existing column to enum type without dropping data
ALTER TABLE "Repo"
ALTER COLUMN "external_codeHostType" TYPE "CodeHostType"
USING "external_codeHostType"::text::"CodeHostType";
31 changes: 29 additions & 2 deletions packages/db/prisma/schema.prisma
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,21 @@ enum ChatVisibility {
PUBLIC
}

/// @note: The @map annotation is required to maintain backwards compatibility
/// with the existing database.
/// @note: In the generated client, these mapped values will be in pascalCase.
/// This behaviour will change in prisma v7. See: https://github.com/prisma/prisma/issues/8446#issuecomment-3356119713
enum CodeHostType {
github
gitlab
gitea
gerrit
bitbucketServer @map("bitbucket-server")
bitbucketCloud @map("bitbucket-cloud")
genericGitHost @map("generic-git-host")
azuredevops
}

model Repo {
id Int @id @default(autoincrement())
name String /// Full repo name, including the vcs hostname (ex. github.com/sourcebot-dev/sourcebot)
Expand All@@ -53,7 +68,7 @@ model Repo {
indexedCommitHash String? /// The commit hash of the last indexed commit (on HEAD).

external_id String /// The id of the repo in the external service
external_codeHostType String /// The type of the external service (e.g., github, gitlab, etc.)
external_codeHostType CodeHostType /// The type of the external service (e.g., github, gitlab, etc.)
external_codeHostUrl String /// The base url of the external service (e.g., https://github.com)

org Org @relation(fields: [orgId], references: [id], onDelete: Cascade)
Expand DownExpand Up@@ -125,6 +140,18 @@ model SearchContext {
@@unique([name, orgId])
}

/// Matches the union of `type` fields in the schema.
/// @see: schemas/v3/connection.type.ts
enum ConnectionType {
github
gitlab
gitea
gerrit
bitbucket
azuredevops
git
}

model Connection {
id Int @id @default(autoincrement())
name String
Expand All@@ -135,7 +162,7 @@ model Connection {
repos RepoToConnection[]

// The type of connection (e.g., github, gitlab, etc.)
connectionType String
connectionType ConnectionType

syncJobs ConnectionSyncJob[]
/// When the connection was last synced successfully.
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ export const CodePreviewPanel = async ({ path, repoName, revisionName }: CodePre
branchDisplayName={revisionName}
/>

{(fileWebUrl && codeHostInfo) && (
{fileWebUrl && (

<a
href={fileWebUrl}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,9 +7,10 @@ import { Badge } from "@/components/ui/badge";
import { Card } from "@/components/ui/card";
import { CardContent } from "@/components/ui/card";
import { DemoExamples, DemoSearchExample, DemoSearchScope } from "@/types";
import { cn, CodeHostType, getCodeHostIcon } from "@/lib/utils";
import { cn, getCodeHostIcon } from "@/lib/utils";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { SearchScopeInfoCard } from "@/features/chat/components/chatBox/searchScopeInfoCard";
import { CodeHostType } from "@sourcebot/db";

interface DemoCards {
demoExamples: DemoExamples;
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/app/[domain]/components/configEditor.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,8 +12,8 @@ import { Separator } from "@/components/ui/separator";
import { Schema } from "ajv";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { CodeHostType } from "@/lib/utils";
import { useCodeMirrorTheme } from "@/hooks/useCodeMirrorTheme";
import { CodeHostType } from "@sourcebot/db";

export type QuickActionFn<T> = (previous: T) => T;
export type QuickAction<T> = {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,10 +9,11 @@ import { Input } from "@/components/ui/input";
import { Separator } from "@/components/ui/separator";
import useCaptureEvent from "@/hooks/useCaptureEvent";
import { useDomain } from "@/hooks/useDomain";
import { CodeHostType, isServiceError } from "@/lib/utils";
import { isServiceError } from "@/lib/utils";
import githubPatCreation from "@/public/github_pat_creation.png";
import gitlabPatCreation from "@/public/gitlab_pat_creation.png";
import giteaPatCreation from "@/public/gitea_pat_creation.png";
import { CodeHostType } from "@sourcebot/db";
import { zodResolver } from "@hookform/resolvers/zod";
import { Eye, EyeOff, Loader2 } from "lucide-react";
import Image from "next/image";
Expand DownExpand Up@@ -88,9 +89,9 @@ export const ImportSecretDialog = ({ open, onOpenChange, onSecretCreated, codeHo
return <GitHubPATCreationStep step={1} />;
case 'gitlab':
return <GitLabPATCreationStep step={1} />;
case 'bitbucket-cloud':
case 'bitbucketCloud':
return <BitbucketCloudPATCreationStep step={1} />;
case 'bitbucket-server':
case 'bitbucketServer':
return <BitbucketServerPATCreationStep step={1} />;
case 'gitea':
return <GiteaPATCreationStep step={1} />;
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@ import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants";
import { RepositoryQuery } from "@/lib/types";
import { getCodeHostInfoForRepo, getShortenedNumberDisplayString } from "@/lib/utils";
import clsx from "clsx";
import { FileIcon, Loader2Icon, RefreshCwIcon } from "lucide-react";
import { Loader2Icon, RefreshCwIcon } from "lucide-react";
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/navigation";
Expand DownExpand Up@@ -90,23 +90,14 @@ const RepoItem = ({ repo }: { repo: RepositoryQuery }) => {
webUrl: repo.webUrl,
});

if (info) {
return {
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}
}

return {
repoIcon: <FileIcon className="w-4 h-4" />,
displayName: repo.repoName,
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}


}, [repo.repoName, repo.codeHostType, repo.repoDisplayName, repo.webUrl]);


Expand Down
22 changes: 9 additions & 13 deletions packages/web/src/app/[domain]/components/pathHeader.tsx
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
'use client';

import { cn, getCodeHostInfoForRepo } from "@/lib/utils";
import { LaptopIcon } from "@radix-ui/react-icons";
import Image from "next/image";
import { getBrowsePath } from "../browse/hooks/utils";
import { ChevronRight, MoreHorizontal } from "lucide-react";
Expand All@@ -17,6 +16,7 @@ import { VscodeFileIcon } from "@/app/components/vscodeFileIcon";
import { CopyIconButton } from "./copyIconButton";
import Link from "next/link";
import { useDomain } from "@/hooks/useDomain";
import { CodeHostType } from "@sourcebot/db";

interface FileHeaderProps {
path: string;
Expand All@@ -27,7 +27,7 @@ interface FileHeaderProps {
pathType?: 'blob' | 'tree';
repo: {
name: string;
codeHostType: string;
codeHostType: CodeHostType;
displayName?: string;
webUrl?: string;
},
Expand DownExpand Up@@ -202,17 +202,13 @@ export const PathHeader = ({
<div className="flex flex-row gap-2 items-center w-full overflow-hidden">
{isCodeHostIconVisible && (
<>
{info?.icon ? (
<a href={info.repoLink} target="_blank" rel="noopener noreferrer">
<Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>
</a>
) : (
<LaptopIcon className="w-4 h-4" />
)}
<a href={info.repoLink} target="_blank" rel="noopener noreferrer">
<Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>
</a>
</>
)}

Expand Down
20 changes: 6 additions & 14 deletions packages/web/src/app/[domain]/components/repositoryCarousel.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,6 @@ import {
import { captureEvent } from "@/hooks/useCaptureEvent";
import { RepositoryQuery } from "@/lib/types";
import { getCodeHostInfoForRepo } from "@/lib/utils";
import { FileIcon } from "@radix-ui/react-icons";
import clsx from "clsx";
import Autoscroll from "embla-carousel-auto-scroll";
import Image from "next/image";
Expand DownExpand Up@@ -121,20 +120,13 @@ const RepositoryBadge = ({
webUrl: repo.webUrl,
});

if (info) {
return {
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
}
}

return {
repoIcon: <FileIcon className="w-4 h-4" />,
displayName: repo.repoName,
repoIcon: <Image
src={info.icon}
alt={info.codeHostName}
className={`w-4 h-4 ${info.iconClassName}`}
/>,
displayName: info.displayName,
Comment thread
brendan-kellam marked this conversation as resolved.
}
})();

Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/app/[domain]/repos/[id]/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,7 +65,7 @@ export default async function RepoDetailPage({ params }: { params: Promise<{ id:
<h1 className="text-3xl font-semibold">{repo.displayName || repo.name}</h1>
<p className="text-muted-foreground mt-2">{repo.name}</p>
</div>
{(codeHostInfo && codeHostInfo.repoLink) && (
{codeHostInfo.repoLink && (
<Button variant="outline" asChild>
<Link href={codeHostInfo.repoLink} target="_blank" rel="noopener noreferrer" className="flex items-center">
<Image
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,13 +15,14 @@ import {
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { CodeHostType, getCodeHostBrowseAtBranchUrl } from "@/lib/utils"
import { getCodeHostBrowseAtBranchUrl } from "@/lib/utils"
import Link from "next/link"
import { CodeHostType } from "@sourcebot/db";

type RepoBranchesTableProps = {
indexRevisions: string[];
repoWebUrl: string | null;
repoCodeHostType: string;
repoCodeHostType: CodeHostType;
}

export const RepoBranchesTable = ({ indexRevisions, repoWebUrl, repoCodeHostType }: RepoBranchesTableProps) => {
Expand All@@ -39,7 +40,7 @@ export const RepoBranchesTable = ({ indexRevisions, repoWebUrl, repoCodeHostType

const branchUrl = getCodeHostBrowseAtBranchUrl({
webUrl: repoWebUrl,
codeHostType: repoCodeHostType as CodeHostType,
codeHostType: repoCodeHostType,
branchName: refName,
});

Expand Down
Loading
Loading