Updates for starred and personal repos

This commit is contained in:
Arunavo Ray
2025-07-18 09:37:38 +05:30
parent d388f2e691
commit 3458891511
6 changed files with 117 additions and 16 deletions

View File

@@ -46,7 +46,7 @@ export function ConfigTabs() {
token: '',
organization: 'github-mirrors',
visibility: 'public',
starredReposOrg: 'github',
starredReposOrg: 'starred',
preserveOrgStructure: false,
},
scheduleConfig: {

View File

@@ -354,6 +354,19 @@ describe("getGiteaRepoOwner - Organization Override Tests", () => {
expect(result).toBe("starred");
});
test("starred repos default to 'starred' org when starredReposOrg is not configured", () => {
const repo = { ...baseRepo, isStarred: true };
const configWithoutStarredOrg = {
...baseConfig,
giteaConfig: {
...baseConfig.giteaConfig,
starredReposOrg: undefined
}
};
const result = getGiteaRepoOwner({ config: configWithoutStarredOrg, repository: repo });
expect(result).toBe("starred");
});
// Removed test for personalReposOrg as this field no longer exists
test("preserve strategy: personal repos fallback to username when no override", () => {

View File

@@ -73,8 +73,8 @@ export const getGiteaRepoOwnerAsync = async ({
}
// Check if repository is starred - starred repos always go to starredReposOrg (highest priority)
if (repository.isStarred && config.giteaConfig.starredReposOrg) {
return config.giteaConfig.starredReposOrg;
if (repository.isStarred) {
return config.giteaConfig.starredReposOrg || "starred";
}
// Check for repository-specific override (second highest priority)
@@ -118,8 +118,8 @@ export const getGiteaRepoOwner = ({
}
// Check if repository is starred - starred repos always go to starredReposOrg
if (repository.isStarred && config.giteaConfig.starredReposOrg) {
return config.giteaConfig.starredReposOrg;
if (repository.isStarred) {
return config.giteaConfig.starredReposOrg || "starred";
}
// Get the mirror strategy - use preserveOrgStructure for backward compatibility
@@ -352,8 +352,8 @@ export const mirrorGithubRepoToGitea = async ({
const apiUrl = `${config.giteaConfig.url}/api/v1/repos/migrate`;
// Handle organization creation if needed for single-org or preserve strategies
if (repoOwner !== config.giteaConfig.defaultOwner && !repository.isStarred) {
// Handle organization creation if needed for single-org, preserve strategies, or starred repos
if (repoOwner !== config.giteaConfig.defaultOwner) {
// Need to create the organization if it doesn't exist
await getOrCreateGiteaOrg({
orgName: repoOwner,

View File

@@ -120,7 +120,7 @@ export function mapDbToUiConfig(dbConfig: any): {
token: dbConfig.giteaConfig?.token || "",
organization: dbConfig.githubConfig?.defaultOrg || "github-mirrors", // Get from GitHub config
visibility: dbConfig.giteaConfig?.visibility === "default" ? "public" : dbConfig.giteaConfig?.visibility || "public",
starredReposOrg: dbConfig.githubConfig?.starredReposOrg || "github", // Get from GitHub config
starredReposOrg: dbConfig.githubConfig?.starredReposOrg || "starred", // Get from GitHub config
preserveOrgStructure: dbConfig.giteaConfig?.preserveVisibility || false, // Map preserveVisibility
mirrorStrategy: dbConfig.githubConfig?.mirrorStrategy || "preserve", // Get from GitHub config
personalReposOrg: undefined, // Not stored in current schema

View File

@@ -200,7 +200,7 @@ export const GET: APIRoute = async ({ request }) => {
includePrivate: false,
includePublic: true,
includeOrganizations: [],
starredReposOrg: "github",
starredReposOrg: "starred",
mirrorStrategy: "preserve",
defaultOrg: "github-mirrors",
},