mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2025-12-10 13:36:45 +03:00
Fix: Starred Repos Organization Bug | Organization Repos Routing
This commit is contained in:
@@ -7,7 +7,7 @@ export const userSchema = z.object({
|
|||||||
id: z.string(),
|
id: z.string(),
|
||||||
username: z.string(),
|
username: z.string(),
|
||||||
password: z.string(),
|
password: z.string(),
|
||||||
email: z.string().email(),
|
email: z.email(),
|
||||||
emailVerified: z.boolean().default(false),
|
emailVerified: z.boolean().default(false),
|
||||||
createdAt: z.coerce.date(),
|
createdAt: z.coerce.date(),
|
||||||
updatedAt: z.coerce.date(),
|
updatedAt: z.coerce.date(),
|
||||||
@@ -29,7 +29,7 @@ export const githubConfigSchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const giteaConfigSchema = z.object({
|
export const giteaConfigSchema = z.object({
|
||||||
url: z.string().url(),
|
url: z.url(),
|
||||||
token: z.string(),
|
token: z.string(),
|
||||||
defaultOwner: z.string(),
|
defaultOwner: z.string(),
|
||||||
mirrorInterval: z.string().default("8h"),
|
mirrorInterval: z.string().default("8h"),
|
||||||
@@ -79,6 +79,7 @@ export const scheduleConfigSchema = z.object({
|
|||||||
|
|
||||||
export const cleanupConfigSchema = z.object({
|
export const cleanupConfigSchema = z.object({
|
||||||
enabled: z.boolean().default(false),
|
enabled: z.boolean().default(false),
|
||||||
|
retentionDays: z.number().default(604800), // 7 days in seconds
|
||||||
deleteFromGitea: z.boolean().default(false),
|
deleteFromGitea: z.boolean().default(false),
|
||||||
deleteIfNotInGitHub: z.boolean().default(true),
|
deleteIfNotInGitHub: z.boolean().default(true),
|
||||||
protectedRepos: z.array(z.string()).default([]),
|
protectedRepos: z.array(z.string()).default([]),
|
||||||
@@ -111,8 +112,8 @@ export const repositorySchema = z.object({
|
|||||||
configId: z.string(),
|
configId: z.string(),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
fullName: z.string(),
|
fullName: z.string(),
|
||||||
url: z.string().url(),
|
url: z.url(),
|
||||||
cloneUrl: z.string().url(),
|
cloneUrl: z.url(),
|
||||||
owner: z.string(),
|
owner: z.string(),
|
||||||
organization: z.string().optional().nullable(),
|
organization: z.string().optional().nullable(),
|
||||||
mirroredLocation: z.string().default(""),
|
mirroredLocation: z.string().default(""),
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export const getGiteaRepoOwnerAsync = async ({
|
|||||||
|
|
||||||
// Check if repository is starred - starred repos always go to starredReposOrg (highest priority)
|
// Check if repository is starred - starred repos always go to starredReposOrg (highest priority)
|
||||||
if (repository.isStarred) {
|
if (repository.isStarred) {
|
||||||
return config.giteaConfig.starredReposOrg || "starred";
|
return config.githubConfig.starredReposOrg || "starred";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for repository-specific override (second highest priority)
|
// Check for repository-specific override (second highest priority)
|
||||||
@@ -119,11 +119,11 @@ export const getGiteaRepoOwner = ({
|
|||||||
|
|
||||||
// Check if repository is starred - starred repos always go to starredReposOrg
|
// Check if repository is starred - starred repos always go to starredReposOrg
|
||||||
if (repository.isStarred) {
|
if (repository.isStarred) {
|
||||||
return config.giteaConfig.starredReposOrg || "starred";
|
return config.githubConfig.starredReposOrg || "starred";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the mirror strategy - use preserveOrgStructure for backward compatibility
|
// Get the mirror strategy - use preserveOrgStructure for backward compatibility
|
||||||
const mirrorStrategy = config.giteaConfig.mirrorStrategy ||
|
const mirrorStrategy = config.githubConfig.mirrorStrategy ||
|
||||||
(config.giteaConfig.preserveOrgStructure ? "preserve" : "flat-user");
|
(config.giteaConfig.preserveOrgStructure ? "preserve" : "flat-user");
|
||||||
|
|
||||||
switch (mirrorStrategy) {
|
switch (mirrorStrategy) {
|
||||||
@@ -897,7 +897,7 @@ export async function mirrorGitHubOrgToGitea({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Get the mirror strategy - use preserveOrgStructure for backward compatibility
|
// Get the mirror strategy - use preserveOrgStructure for backward compatibility
|
||||||
const mirrorStrategy = config.giteaConfig?.mirrorStrategy ||
|
const mirrorStrategy = config.githubConfig?.mirrorStrategy ||
|
||||||
(config.giteaConfig?.preserveOrgStructure ? "preserve" : "flat-user");
|
(config.giteaConfig?.preserveOrgStructure ? "preserve" : "flat-user");
|
||||||
|
|
||||||
let giteaOrgId: number;
|
let giteaOrgId: number;
|
||||||
@@ -906,7 +906,7 @@ export async function mirrorGitHubOrgToGitea({
|
|||||||
// Determine the target organization based on strategy
|
// Determine the target organization based on strategy
|
||||||
if (mirrorStrategy === "single-org" && config.giteaConfig?.organization) {
|
if (mirrorStrategy === "single-org" && config.giteaConfig?.organization) {
|
||||||
// For single-org strategy, use the configured destination organization
|
// For single-org strategy, use the configured destination organization
|
||||||
targetOrgName = config.giteaConfig.defaultOrg || config.giteaConfig.defaultOwner;
|
targetOrgName = config.giteaConfig.organization || config.giteaConfig.defaultOwner;
|
||||||
giteaOrgId = await getOrCreateGiteaOrg({
|
giteaOrgId = await getOrCreateGiteaOrg({
|
||||||
orgId: organization.id,
|
orgId: organization.id,
|
||||||
orgName: targetOrgName,
|
orgName: targetOrgName,
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ export function mapDbScheduleToUi(dbSchedule: DbScheduleConfig): any {
|
|||||||
export function mapUiCleanupToDb(uiCleanup: any): DbCleanupConfig {
|
export function mapUiCleanupToDb(uiCleanup: any): DbCleanupConfig {
|
||||||
return {
|
return {
|
||||||
enabled: uiCleanup.enabled || false,
|
enabled: uiCleanup.enabled || false,
|
||||||
|
retentionDays: uiCleanup.retentionDays || 604800, // Default to 7 days
|
||||||
deleteFromGitea: false,
|
deleteFromGitea: false,
|
||||||
deleteIfNotInGitHub: true,
|
deleteIfNotInGitHub: true,
|
||||||
protectedRepos: [],
|
protectedRepos: [],
|
||||||
@@ -218,6 +219,6 @@ export function mapUiCleanupToDb(uiCleanup: any): DbCleanupConfig {
|
|||||||
export function mapDbCleanupToUi(dbCleanup: DbCleanupConfig): any {
|
export function mapDbCleanupToUi(dbCleanup: DbCleanupConfig): any {
|
||||||
return {
|
return {
|
||||||
enabled: dbCleanup.enabled,
|
enabled: dbCleanup.enabled,
|
||||||
retentionDays: 604800, // 7 days in seconds (kept for compatibility)
|
retentionDays: dbCleanup.retentionDays || 604800, // Use actual value from DB or default to 7 days
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ export const POST: APIRoute = async ({ request }) => {
|
|||||||
|
|
||||||
// For single-org and starred repos strategies, or when mirroring to an org,
|
// For single-org and starred repos strategies, or when mirroring to an org,
|
||||||
// always use the org mirroring function to ensure proper organization handling
|
// always use the org mirroring function to ensure proper organization handling
|
||||||
const mirrorStrategy = config.giteaConfig?.mirrorStrategy ||
|
const mirrorStrategy = config.githubConfig?.mirrorStrategy ||
|
||||||
(config.githubConfig?.preserveOrgStructure ? "preserve" : "flat-user");
|
(config.githubConfig?.preserveOrgStructure ? "preserve" : "flat-user");
|
||||||
|
|
||||||
const shouldUseOrgMirror =
|
const shouldUseOrgMirror =
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ export const POST: APIRoute = async ({ request }) => {
|
|||||||
|
|
||||||
// For single-org and starred repos strategies, or when mirroring to an org,
|
// For single-org and starred repos strategies, or when mirroring to an org,
|
||||||
// always use the org mirroring function to ensure proper organization handling
|
// always use the org mirroring function to ensure proper organization handling
|
||||||
const mirrorStrategy = config.giteaConfig?.mirrorStrategy ||
|
const mirrorStrategy = config.githubConfig?.mirrorStrategy ||
|
||||||
(config.githubConfig?.preserveOrgStructure ? "preserve" : "flat-user");
|
(config.githubConfig?.preserveOrgStructure ? "preserve" : "flat-user");
|
||||||
|
|
||||||
const shouldUseOrgMirror =
|
const shouldUseOrgMirror =
|
||||||
|
|||||||
Reference in New Issue
Block a user