From e94de5c9caf2e2150a3585cbd0e09598f99d5caf Mon Sep 17 00:00:00 2001 From: Arunavo Ray Date: Tue, 17 Jun 2025 11:35:09 +0530 Subject: [PATCH] fix: mirror to one org issue --- src/components/ui/tooltip.tsx | 8 ++++++-- src/content/config.ts | 17 ++--------------- src/pages/api/job/mirror-repo.ts | 13 +++++++++++-- src/pages/api/job/retry-repo.ts | 13 +++++++++++-- 4 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/components/ui/tooltip.tsx b/src/components/ui/tooltip.tsx index 012ad74..71ee0fe 100644 --- a/src/components/ui/tooltip.tsx +++ b/src/components/ui/tooltip.tsx @@ -19,7 +19,11 @@ function TooltipProvider({ function Tooltip({ ...props }: React.ComponentProps) { - return + return ( + + + + ) } function TooltipTrigger({ @@ -40,7 +44,7 @@ function TooltipContent({ data-slot="tooltip-content" sideOffset={sideOffset} className={cn( - "bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-[var(--radix-tooltip-content-transform-origin)] rounded-md px-3 py-1.5 text-xs text-balance", + "bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance", className )} {...props} diff --git a/src/content/config.ts b/src/content/config.ts index c013911..8f00fbf 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -1,17 +1,4 @@ import { defineCollection, z } from 'astro:content'; -// Define a schema for the documentation collection -const docsCollection = defineCollection({ - type: 'content', - schema: z.object({ - title: z.string(), - description: z.string(), - order: z.number().optional(), - updatedDate: z.date().optional(), - }), -}); - -// Export the collections -export const collections = { - 'docs': docsCollection, -}; +// Export empty collections since docs have been moved +export const collections = {}; diff --git a/src/pages/api/job/mirror-repo.ts b/src/pages/api/job/mirror-repo.ts index 4854eb0..95ee671 100644 --- a/src/pages/api/job/mirror-repo.ts +++ b/src/pages/api/job/mirror-repo.ts @@ -105,8 +105,17 @@ export const POST: APIRoute = async ({ request }) => { console.log(`Repository ${repo.name} will be mirrored to owner: ${owner}`); - // Check if owner is different from the user (means it's going to an org) - if (owner !== config.giteaConfig?.username) { + // For single-org and starred repos strategies, or when mirroring to an org, + // always use the org mirroring function to ensure proper organization handling + const mirrorStrategy = config.giteaConfig?.mirrorStrategy || + (config.githubConfig?.preserveOrgStructure ? "preserve" : "flat-user"); + + const shouldUseOrgMirror = + owner !== config.giteaConfig?.username || // Different owner means org + mirrorStrategy === "single-org" || // Single-org strategy always uses org + repoData.isStarred; // Starred repos always go to org + + if (shouldUseOrgMirror) { await mirrorGitHubOrgRepoToGiteaOrg({ config, octokit, diff --git a/src/pages/api/job/retry-repo.ts b/src/pages/api/job/retry-repo.ts index c2c2fbc..fc191a0 100644 --- a/src/pages/api/job/retry-repo.ts +++ b/src/pages/api/job/retry-repo.ts @@ -137,8 +137,17 @@ export const POST: APIRoute = async ({ request }) => { console.log(`Importing repo: ${repo.name} to owner: ${owner}`); - // Check if owner is different from the user (means it's going to an org) - if (owner !== config.giteaConfig?.username) { + // For single-org and starred repos strategies, or when mirroring to an org, + // always use the org mirroring function to ensure proper organization handling + const mirrorStrategy = config.giteaConfig?.mirrorStrategy || + (config.githubConfig?.preserveOrgStructure ? "preserve" : "flat-user"); + + const shouldUseOrgMirror = + owner !== config.giteaConfig?.username || // Different owner means org + mirrorStrategy === "single-org" || // Single-org strategy always uses org + repoData.isStarred; // Starred repos always go to org + + if (shouldUseOrgMirror) { await mirrorGitHubOrgRepoToGiteaOrg({ config, octokit,