From 85ea5022764cce77b1e42b220c55cca0bb89fade Mon Sep 17 00:00:00 2001 From: Arunavo Ray Date: Fri, 3 Oct 2025 09:13:58 +0530 Subject: [PATCH] fix: apply skipStarredIssues flag to all metadata types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, the skipStarredIssues flag (Lightweight mode for starred repos) only applied to issues. This caused starred repos to mirror all metadata (pull requests, labels, milestones, wiki) even when "code-only" was selected. Fixed by applying the skipStarredIssues check to: - Pull requests mirroring - Labels mirroring - Milestones mirroring - Wiki mirroring (in migration payload) Now starred repos with "code-only" mode truly mirror only source code, skipping all metadata as intended. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/lib/gitea.ts | 66 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/src/lib/gitea.ts b/src/lib/gitea.ts index 5e09b15..6a6fce9 100644 --- a/src/lib/gitea.ts +++ b/src/lib/gitea.ts @@ -423,12 +423,16 @@ export const mirrorGithubRepoToGitea = async ({ // Prepare migration payload // For private repos, use separate auth fields instead of embedding credentials in URL // This is required for Forgejo 12+ which rejects URLs with embedded credentials + // Skip wiki for starred repos if skipStarredIssues is enabled + const shouldMirrorWiki = config.giteaConfig?.wiki && + !(repository.isStarred && config.githubConfig?.skipStarredIssues); + const migratePayload: any = { clone_addr: cloneAddress, repo_name: targetRepoName, mirror: true, mirror_interval: config.giteaConfig?.mirrorInterval || "8h", - wiki: config.giteaConfig?.wiki || false, + wiki: shouldMirrorWiki || false, lfs: config.giteaConfig?.lfs || false, private: repository.isPrivate, repo_owner: repoOwner, @@ -498,8 +502,13 @@ export const mirrorGithubRepoToGitea = async ({ } // Mirror pull requests if enabled - console.log(`[Metadata] Pull request mirroring check: mirrorPullRequests=${config.giteaConfig?.mirrorPullRequests}`); - if (config.giteaConfig?.mirrorPullRequests) { + // Skip pull requests for starred repos if skipStarredIssues is enabled + const shouldMirrorPullRequests = config.giteaConfig?.mirrorPullRequests && + !(repository.isStarred && config.githubConfig?.skipStarredIssues); + + console.log(`[Metadata] Pull request mirroring check: mirrorPullRequests=${config.giteaConfig?.mirrorPullRequests}, isStarred=${repository.isStarred}, skipStarredIssues=${config.githubConfig?.skipStarredIssues}, shouldMirrorPullRequests=${shouldMirrorPullRequests}`); + + if (shouldMirrorPullRequests) { try { await mirrorGitRepoPullRequestsToGitea({ config, @@ -516,8 +525,13 @@ export const mirrorGithubRepoToGitea = async ({ } // Mirror labels if enabled (and not already done via issues) - console.log(`[Metadata] Label mirroring check: mirrorLabels=${config.giteaConfig?.mirrorLabels}, shouldMirrorIssues=${shouldMirrorIssues}`); - if (config.giteaConfig?.mirrorLabels && !shouldMirrorIssues) { + // Skip labels for starred repos if skipStarredIssues is enabled + const shouldMirrorLabels = config.giteaConfig?.mirrorLabels && !shouldMirrorIssues && + !(repository.isStarred && config.githubConfig?.skipStarredIssues); + + console.log(`[Metadata] Label mirroring check: mirrorLabels=${config.giteaConfig?.mirrorLabels}, shouldMirrorIssues=${shouldMirrorIssues}, isStarred=${repository.isStarred}, skipStarredIssues=${config.githubConfig?.skipStarredIssues}, shouldMirrorLabels=${shouldMirrorLabels}`); + + if (shouldMirrorLabels) { try { await mirrorGitRepoLabelsToGitea({ config, @@ -534,8 +548,13 @@ export const mirrorGithubRepoToGitea = async ({ } // Mirror milestones if enabled - console.log(`[Metadata] Milestone mirroring check: mirrorMilestones=${config.giteaConfig?.mirrorMilestones}`); - if (config.giteaConfig?.mirrorMilestones) { + // Skip milestones for starred repos if skipStarredIssues is enabled + const shouldMirrorMilestones = config.giteaConfig?.mirrorMilestones && + !(repository.isStarred && config.githubConfig?.skipStarredIssues); + + console.log(`[Metadata] Milestone mirroring check: mirrorMilestones=${config.giteaConfig?.mirrorMilestones}, isStarred=${repository.isStarred}, skipStarredIssues=${config.githubConfig?.skipStarredIssues}, shouldMirrorMilestones=${shouldMirrorMilestones}`); + + if (shouldMirrorMilestones) { try { await mirrorGitRepoMilestonesToGitea({ config, @@ -824,13 +843,17 @@ export async function mirrorGitHubRepoToGiteaOrg({ // Prepare migration payload // For private repos, use separate auth fields instead of embedding credentials in URL // This is required for Forgejo 12+ which rejects URLs with embedded credentials + // Skip wiki for starred repos if skipStarredIssues is enabled + const shouldMirrorWiki = config.giteaConfig?.wiki && + !(repository.isStarred && config.githubConfig?.skipStarredIssues); + const migratePayload: any = { clone_addr: cloneAddress, uid: giteaOrgId, repo_name: targetRepoName, mirror: true, mirror_interval: config.giteaConfig?.mirrorInterval || "8h", - wiki: config.giteaConfig?.wiki || false, + wiki: shouldMirrorWiki || false, lfs: config.giteaConfig?.lfs || false, private: repository.isPrivate, }; @@ -897,8 +920,13 @@ export async function mirrorGitHubRepoToGiteaOrg({ } // Mirror pull requests if enabled - console.log(`[Metadata] Pull request mirroring check: mirrorPullRequests=${config.giteaConfig?.mirrorPullRequests}`); - if (config.giteaConfig?.mirrorPullRequests) { + // Skip pull requests for starred repos if skipStarredIssues is enabled + const shouldMirrorPullRequests = config.giteaConfig?.mirrorPullRequests && + !(repository.isStarred && config.githubConfig?.skipStarredIssues); + + console.log(`[Metadata] Pull request mirroring check: mirrorPullRequests=${config.giteaConfig?.mirrorPullRequests}, isStarred=${repository.isStarred}, skipStarredIssues=${config.githubConfig?.skipStarredIssues}, shouldMirrorPullRequests=${shouldMirrorPullRequests}`); + + if (shouldMirrorPullRequests) { try { await mirrorGitRepoPullRequestsToGitea({ config, @@ -915,8 +943,13 @@ export async function mirrorGitHubRepoToGiteaOrg({ } // Mirror labels if enabled (and not already done via issues) - console.log(`[Metadata] Label mirroring check: mirrorLabels=${config.giteaConfig?.mirrorLabels}, shouldMirrorIssues=${shouldMirrorIssues}`); - if (config.giteaConfig?.mirrorLabels && !shouldMirrorIssues) { + // Skip labels for starred repos if skipStarredIssues is enabled + const shouldMirrorLabels = config.giteaConfig?.mirrorLabels && !shouldMirrorIssues && + !(repository.isStarred && config.githubConfig?.skipStarredIssues); + + console.log(`[Metadata] Label mirroring check: mirrorLabels=${config.giteaConfig?.mirrorLabels}, shouldMirrorIssues=${shouldMirrorIssues}, isStarred=${repository.isStarred}, skipStarredIssues=${config.githubConfig?.skipStarredIssues}, shouldMirrorLabels=${shouldMirrorLabels}`); + + if (shouldMirrorLabels) { try { await mirrorGitRepoLabelsToGitea({ config, @@ -933,8 +966,13 @@ export async function mirrorGitHubRepoToGiteaOrg({ } // Mirror milestones if enabled - console.log(`[Metadata] Milestone mirroring check: mirrorMilestones=${config.giteaConfig?.mirrorMilestones}`); - if (config.giteaConfig?.mirrorMilestones) { + // Skip milestones for starred repos if skipStarredIssues is enabled + const shouldMirrorMilestones = config.giteaConfig?.mirrorMilestones && + !(repository.isStarred && config.githubConfig?.skipStarredIssues); + + console.log(`[Metadata] Milestone mirroring check: mirrorMilestones=${config.giteaConfig?.mirrorMilestones}, isStarred=${repository.isStarred}, skipStarredIssues=${config.githubConfig?.skipStarredIssues}, shouldMirrorMilestones=${shouldMirrorMilestones}`); + + if (shouldMirrorMilestones) { try { await mirrorGitRepoMilestonesToGitea({ config,