mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2025-12-09 04:56:45 +03:00
Fixed Private Repo Issues
This commit is contained in:
@@ -281,6 +281,7 @@ export function OrganizationList({
|
||||
<div className="flex items-center gap-3">
|
||||
<Skeleton className="h-4 w-20" />
|
||||
<Skeleton className="h-4 w-20" />
|
||||
<Skeleton className="h-4 w-20" />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-center gap-3">
|
||||
@@ -300,6 +301,14 @@ export function OrganizationList({
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{org.forkRepositoryCount !== undefined && org.forkRepositoryCount > 0 && (
|
||||
<div className="flex items-center gap-1.5">
|
||||
<div className="h-2.5 w-2.5 rounded-full bg-blue-500" />
|
||||
<span className="text-muted-foreground">
|
||||
{org.forkRepositoryCount} {org.forkRepositoryCount === 1 ? "fork" : "forks"}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -52,13 +52,11 @@ export async function getGithubRepositories({
|
||||
{ per_page: 100 }
|
||||
);
|
||||
|
||||
const includePrivate = config.githubConfig?.privateRepositories ?? false;
|
||||
const skipForks = config.githubConfig?.skipForks ?? false;
|
||||
|
||||
const filteredRepos = repos.filter((repo) => {
|
||||
const isPrivateAllowed = includePrivate || !repo.private;
|
||||
const isForkAllowed = !skipForks || !repo.fork;
|
||||
return isPrivateAllowed && isForkAllowed;
|
||||
return isForkAllowed;
|
||||
});
|
||||
|
||||
return filteredRepos.map((repo) => ({
|
||||
|
||||
@@ -91,29 +91,27 @@ export const GET: APIRoute = async ({ request }) => {
|
||||
.from(repositories)
|
||||
.where(and(...publicConditions));
|
||||
|
||||
// Get private count (only if private repos are enabled in config)
|
||||
const [privateCount] = githubConfig.privateRepositories ? await db
|
||||
// Get private count (always show actual count regardless of config)
|
||||
const [privateCount] = await db
|
||||
.select({ count: count() })
|
||||
.from(repositories)
|
||||
.where(
|
||||
and(
|
||||
...baseConditions,
|
||||
eq(repositories.isPrivate, true),
|
||||
...(githubConfig.skipForks ? [eq(repositories.isForked, false)] : [])
|
||||
eq(repositories.isPrivate, true)
|
||||
)
|
||||
) : [{ count: 0 }];
|
||||
);
|
||||
|
||||
// Get fork count (only if forks are enabled in config)
|
||||
const [forkCount] = !githubConfig.skipForks ? await db
|
||||
// Get fork count (always show actual count regardless of config)
|
||||
const [forkCount] = await db
|
||||
.select({ count: count() })
|
||||
.from(repositories)
|
||||
.where(
|
||||
and(
|
||||
...baseConditions,
|
||||
eq(repositories.isForked, true),
|
||||
...(!githubConfig.privateRepositories ? [eq(repositories.isPrivate, false)] : [])
|
||||
eq(repositories.isForked, true)
|
||||
)
|
||||
) : [{ count: 0 }];
|
||||
);
|
||||
|
||||
return {
|
||||
...org,
|
||||
|
||||
@@ -78,7 +78,7 @@ export const POST: APIRoute = async ({ request }) => {
|
||||
// Fetch repos based on config settings
|
||||
const allRepos = [];
|
||||
|
||||
// Always fetch public repos
|
||||
// Fetch all repos (public, private, and member) to show in UI
|
||||
const publicRepos = await octokit.paginate(octokit.repos.listForOrg, {
|
||||
org,
|
||||
type: "public",
|
||||
@@ -86,28 +86,24 @@ export const POST: APIRoute = async ({ request }) => {
|
||||
});
|
||||
allRepos.push(...publicRepos);
|
||||
|
||||
// Fetch private repos if enabled in config
|
||||
if (decryptedConfig.githubConfig?.includePrivate) {
|
||||
const privateRepos = await octokit.paginate(octokit.repos.listForOrg, {
|
||||
org,
|
||||
type: "private",
|
||||
per_page: 100,
|
||||
});
|
||||
allRepos.push(...privateRepos);
|
||||
}
|
||||
// Always fetch private repos to show them in the UI
|
||||
const privateRepos = await octokit.paginate(octokit.repos.listForOrg, {
|
||||
org,
|
||||
type: "private",
|
||||
per_page: 100,
|
||||
});
|
||||
allRepos.push(...privateRepos);
|
||||
|
||||
// Also fetch member repos (includes private repos the user has access to)
|
||||
if (decryptedConfig.githubConfig?.includePrivate) {
|
||||
const memberRepos = await octokit.paginate(octokit.repos.listForOrg, {
|
||||
org,
|
||||
type: "member",
|
||||
per_page: 100,
|
||||
});
|
||||
// Filter out duplicates
|
||||
const existingIds = new Set(allRepos.map(r => r.id));
|
||||
const uniqueMemberRepos = memberRepos.filter(r => !existingIds.has(r.id));
|
||||
allRepos.push(...uniqueMemberRepos);
|
||||
}
|
||||
const memberRepos = await octokit.paginate(octokit.repos.listForOrg, {
|
||||
org,
|
||||
type: "member",
|
||||
per_page: 100,
|
||||
});
|
||||
// Filter out duplicates
|
||||
const existingIds = new Set(allRepos.map(r => r.id));
|
||||
const uniqueMemberRepos = memberRepos.filter(r => !existingIds.has(r.id));
|
||||
allRepos.push(...uniqueMemberRepos);
|
||||
|
||||
// Insert repositories
|
||||
const repoRecords = allRepos.map((repo) => ({
|
||||
|
||||
Reference in New Issue
Block a user