mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2025-12-14 07:26:44 +03:00
Issue 68
This commit is contained in:
194
src/lib/gitea.ts
194
src/lib/gitea.ts
@@ -431,11 +431,17 @@ export const mirrorGithubRepoToGitea = async ({
|
|||||||
//mirror releases
|
//mirror releases
|
||||||
console.log(`[Metadata] Release mirroring check: mirrorReleases=${config.giteaConfig?.mirrorReleases}`);
|
console.log(`[Metadata] Release mirroring check: mirrorReleases=${config.giteaConfig?.mirrorReleases}`);
|
||||||
if (config.giteaConfig?.mirrorReleases) {
|
if (config.giteaConfig?.mirrorReleases) {
|
||||||
await mirrorGitHubReleasesToGitea({
|
try {
|
||||||
config,
|
await mirrorGitHubReleasesToGitea({
|
||||||
octokit,
|
config,
|
||||||
repository,
|
octokit,
|
||||||
});
|
repository,
|
||||||
|
});
|
||||||
|
console.log(`[Metadata] Successfully mirrored releases for ${repository.name}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`[Metadata] Failed to mirror releases for ${repository.name}: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
|
// Continue with other operations even if releases fail
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clone issues
|
// clone issues
|
||||||
@@ -446,45 +452,69 @@ export const mirrorGithubRepoToGitea = async ({
|
|||||||
console.log(`[Metadata] Issue mirroring check: mirrorIssues=${config.giteaConfig?.mirrorIssues}, isStarred=${repository.isStarred}, skipStarredIssues=${config.githubConfig?.skipStarredIssues}, shouldMirrorIssues=${shouldMirrorIssues}`);
|
console.log(`[Metadata] Issue mirroring check: mirrorIssues=${config.giteaConfig?.mirrorIssues}, isStarred=${repository.isStarred}, skipStarredIssues=${config.githubConfig?.skipStarredIssues}, shouldMirrorIssues=${shouldMirrorIssues}`);
|
||||||
|
|
||||||
if (shouldMirrorIssues) {
|
if (shouldMirrorIssues) {
|
||||||
await mirrorGitRepoIssuesToGitea({
|
try {
|
||||||
config,
|
await mirrorGitRepoIssuesToGitea({
|
||||||
octokit,
|
config,
|
||||||
repository,
|
octokit,
|
||||||
giteaOwner: repoOwner,
|
repository,
|
||||||
});
|
giteaOwner: repoOwner,
|
||||||
|
});
|
||||||
|
console.log(`[Metadata] Successfully mirrored issues for ${repository.name}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`[Metadata] Failed to mirror issues for ${repository.name}: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
|
// Continue with other metadata operations even if issues fail
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mirror pull requests if enabled
|
// Mirror pull requests if enabled
|
||||||
console.log(`[Metadata] Pull request mirroring check: mirrorPullRequests=${config.giteaConfig?.mirrorPullRequests}`);
|
console.log(`[Metadata] Pull request mirroring check: mirrorPullRequests=${config.giteaConfig?.mirrorPullRequests}`);
|
||||||
if (config.giteaConfig?.mirrorPullRequests) {
|
if (config.giteaConfig?.mirrorPullRequests) {
|
||||||
await mirrorGitRepoPullRequestsToGitea({
|
try {
|
||||||
config,
|
await mirrorGitRepoPullRequestsToGitea({
|
||||||
octokit,
|
config,
|
||||||
repository,
|
octokit,
|
||||||
giteaOwner: repoOwner,
|
repository,
|
||||||
});
|
giteaOwner: repoOwner,
|
||||||
|
});
|
||||||
|
console.log(`[Metadata] Successfully mirrored pull requests for ${repository.name}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`[Metadata] Failed to mirror pull requests for ${repository.name}: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
|
// Continue with other metadata operations even if PRs fail
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mirror labels if enabled (and not already done via issues)
|
// Mirror labels if enabled (and not already done via issues)
|
||||||
console.log(`[Metadata] Label mirroring check: mirrorLabels=${config.giteaConfig?.mirrorLabels}, shouldMirrorIssues=${shouldMirrorIssues}`);
|
console.log(`[Metadata] Label mirroring check: mirrorLabels=${config.giteaConfig?.mirrorLabels}, shouldMirrorIssues=${shouldMirrorIssues}`);
|
||||||
if (config.giteaConfig?.mirrorLabels && !shouldMirrorIssues) {
|
if (config.giteaConfig?.mirrorLabels && !shouldMirrorIssues) {
|
||||||
await mirrorGitRepoLabelsToGitea({
|
try {
|
||||||
config,
|
await mirrorGitRepoLabelsToGitea({
|
||||||
octokit,
|
config,
|
||||||
repository,
|
octokit,
|
||||||
giteaOwner: repoOwner,
|
repository,
|
||||||
});
|
giteaOwner: repoOwner,
|
||||||
|
});
|
||||||
|
console.log(`[Metadata] Successfully mirrored labels for ${repository.name}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`[Metadata] Failed to mirror labels for ${repository.name}: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
|
// Continue with other metadata operations even if labels fail
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mirror milestones if enabled
|
// Mirror milestones if enabled
|
||||||
console.log(`[Metadata] Milestone mirroring check: mirrorMilestones=${config.giteaConfig?.mirrorMilestones}`);
|
console.log(`[Metadata] Milestone mirroring check: mirrorMilestones=${config.giteaConfig?.mirrorMilestones}`);
|
||||||
if (config.giteaConfig?.mirrorMilestones) {
|
if (config.giteaConfig?.mirrorMilestones) {
|
||||||
await mirrorGitRepoMilestonesToGitea({
|
try {
|
||||||
config,
|
await mirrorGitRepoMilestonesToGitea({
|
||||||
octokit,
|
config,
|
||||||
repository,
|
octokit,
|
||||||
giteaOwner: repoOwner,
|
repository,
|
||||||
});
|
giteaOwner: repoOwner,
|
||||||
|
});
|
||||||
|
console.log(`[Metadata] Successfully mirrored milestones for ${repository.name}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`[Metadata] Failed to mirror milestones for ${repository.name}: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
|
// Continue with other metadata operations even if milestones fail
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Repository ${repository.name} mirrored successfully`);
|
console.log(`Repository ${repository.name} mirrored successfully`);
|
||||||
@@ -691,11 +721,17 @@ export async function mirrorGitHubRepoToGiteaOrg({
|
|||||||
//mirror releases
|
//mirror releases
|
||||||
console.log(`[Metadata] Release mirroring check: mirrorReleases=${config.giteaConfig?.mirrorReleases}`);
|
console.log(`[Metadata] Release mirroring check: mirrorReleases=${config.giteaConfig?.mirrorReleases}`);
|
||||||
if (config.giteaConfig?.mirrorReleases) {
|
if (config.giteaConfig?.mirrorReleases) {
|
||||||
await mirrorGitHubReleasesToGitea({
|
try {
|
||||||
config,
|
await mirrorGitHubReleasesToGitea({
|
||||||
octokit,
|
config,
|
||||||
repository,
|
octokit,
|
||||||
});
|
repository,
|
||||||
|
});
|
||||||
|
console.log(`[Metadata] Successfully mirrored releases for ${repository.name}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`[Metadata] Failed to mirror releases for ${repository.name}: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
|
// Continue with other operations even if releases fail
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clone issues
|
// Clone issues
|
||||||
@@ -703,46 +739,72 @@ export async function mirrorGitHubRepoToGiteaOrg({
|
|||||||
const shouldMirrorIssues = config.giteaConfig?.mirrorIssues &&
|
const shouldMirrorIssues = config.giteaConfig?.mirrorIssues &&
|
||||||
!(repository.isStarred && config.githubConfig?.skipStarredIssues);
|
!(repository.isStarred && config.githubConfig?.skipStarredIssues);
|
||||||
|
|
||||||
|
console.log(`[Metadata] Issue mirroring check: mirrorIssues=${config.giteaConfig?.mirrorIssues}, isStarred=${repository.isStarred}, skipStarredIssues=${config.githubConfig?.skipStarredIssues}, shouldMirrorIssues=${shouldMirrorIssues}`);
|
||||||
|
|
||||||
if (shouldMirrorIssues) {
|
if (shouldMirrorIssues) {
|
||||||
await mirrorGitRepoIssuesToGitea({
|
try {
|
||||||
config,
|
await mirrorGitRepoIssuesToGitea({
|
||||||
octokit,
|
config,
|
||||||
repository,
|
octokit,
|
||||||
giteaOwner: orgName,
|
repository,
|
||||||
});
|
giteaOwner: orgName,
|
||||||
|
});
|
||||||
|
console.log(`[Metadata] Successfully mirrored issues for ${repository.name} to org ${orgName}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`[Metadata] Failed to mirror issues for ${repository.name} to org ${orgName}: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
|
// Continue with other metadata operations even if issues fail
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mirror pull requests if enabled
|
// Mirror pull requests if enabled
|
||||||
console.log(`[Metadata] Pull request mirroring check: mirrorPullRequests=${config.giteaConfig?.mirrorPullRequests}`);
|
console.log(`[Metadata] Pull request mirroring check: mirrorPullRequests=${config.giteaConfig?.mirrorPullRequests}`);
|
||||||
if (config.giteaConfig?.mirrorPullRequests) {
|
if (config.giteaConfig?.mirrorPullRequests) {
|
||||||
await mirrorGitRepoPullRequestsToGitea({
|
try {
|
||||||
config,
|
await mirrorGitRepoPullRequestsToGitea({
|
||||||
octokit,
|
config,
|
||||||
repository,
|
octokit,
|
||||||
giteaOwner: orgName,
|
repository,
|
||||||
});
|
giteaOwner: orgName,
|
||||||
|
});
|
||||||
|
console.log(`[Metadata] Successfully mirrored pull requests for ${repository.name} to org ${orgName}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`[Metadata] Failed to mirror pull requests for ${repository.name} to org ${orgName}: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
|
// Continue with other metadata operations even if PRs fail
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mirror labels if enabled (and not already done via issues)
|
// Mirror labels if enabled (and not already done via issues)
|
||||||
console.log(`[Metadata] Label mirroring check: mirrorLabels=${config.giteaConfig?.mirrorLabels}, shouldMirrorIssues=${shouldMirrorIssues}`);
|
console.log(`[Metadata] Label mirroring check: mirrorLabels=${config.giteaConfig?.mirrorLabels}, shouldMirrorIssues=${shouldMirrorIssues}`);
|
||||||
if (config.giteaConfig?.mirrorLabels && !shouldMirrorIssues) {
|
if (config.giteaConfig?.mirrorLabels && !shouldMirrorIssues) {
|
||||||
await mirrorGitRepoLabelsToGitea({
|
try {
|
||||||
config,
|
await mirrorGitRepoLabelsToGitea({
|
||||||
octokit,
|
config,
|
||||||
repository,
|
octokit,
|
||||||
giteaOwner: orgName,
|
repository,
|
||||||
});
|
giteaOwner: orgName,
|
||||||
|
});
|
||||||
|
console.log(`[Metadata] Successfully mirrored labels for ${repository.name} to org ${orgName}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`[Metadata] Failed to mirror labels for ${repository.name} to org ${orgName}: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
|
// Continue with other metadata operations even if labels fail
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mirror milestones if enabled
|
// Mirror milestones if enabled
|
||||||
console.log(`[Metadata] Milestone mirroring check: mirrorMilestones=${config.giteaConfig?.mirrorMilestones}`);
|
console.log(`[Metadata] Milestone mirroring check: mirrorMilestones=${config.giteaConfig?.mirrorMilestones}`);
|
||||||
if (config.giteaConfig?.mirrorMilestones) {
|
if (config.giteaConfig?.mirrorMilestones) {
|
||||||
await mirrorGitRepoMilestonesToGitea({
|
try {
|
||||||
config,
|
await mirrorGitRepoMilestonesToGitea({
|
||||||
octokit,
|
config,
|
||||||
repository,
|
octokit,
|
||||||
giteaOwner: orgName,
|
repository,
|
||||||
});
|
giteaOwner: orgName,
|
||||||
|
});
|
||||||
|
console.log(`[Metadata] Successfully mirrored milestones for ${repository.name} to org ${orgName}`);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`[Metadata] Failed to mirror milestones for ${repository.name} to org ${orgName}: ${error instanceof Error ? error.message : String(error)}`);
|
||||||
|
// Continue with other metadata operations even if milestones fail
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
@@ -1094,7 +1156,7 @@ export const mirrorGitRepoIssuesToGitea = async ({
|
|||||||
!config.githubConfig?.token ||
|
!config.githubConfig?.token ||
|
||||||
!config.giteaConfig?.token ||
|
!config.giteaConfig?.token ||
|
||||||
!config.giteaConfig?.url ||
|
!config.giteaConfig?.url ||
|
||||||
!config.giteaConfig?.username
|
!config.giteaConfig?.defaultOwner
|
||||||
) {
|
) {
|
||||||
throw new Error("Missing GitHub or Gitea configuration.");
|
throw new Error("Missing GitHub or Gitea configuration.");
|
||||||
}
|
}
|
||||||
@@ -1102,6 +1164,12 @@ export const mirrorGitRepoIssuesToGitea = async ({
|
|||||||
// Decrypt config tokens for API usage
|
// Decrypt config tokens for API usage
|
||||||
const decryptedConfig = decryptConfigTokens(config as Config);
|
const decryptedConfig = decryptConfigTokens(config as Config);
|
||||||
|
|
||||||
|
// Log configuration details for debugging
|
||||||
|
console.log(`[Issues] Starting issue mirroring for repository ${repository.name}`);
|
||||||
|
console.log(`[Issues] Gitea URL: ${config.giteaConfig!.url}`);
|
||||||
|
console.log(`[Issues] Gitea Owner: ${giteaOwner}`);
|
||||||
|
console.log(`[Issues] Gitea Default Owner: ${config.giteaConfig!.defaultOwner}`);
|
||||||
|
|
||||||
// Verify the repository exists in Gitea before attempting to mirror metadata
|
// Verify the repository exists in Gitea before attempting to mirror metadata
|
||||||
console.log(`[Issues] Verifying repository ${repository.name} exists at ${giteaOwner}`);
|
console.log(`[Issues] Verifying repository ${repository.name} exists at ${giteaOwner}`);
|
||||||
const repoExists = await isRepoPresentInGitea({
|
const repoExists = await isRepoPresentInGitea({
|
||||||
@@ -1450,7 +1518,7 @@ export async function mirrorGitRepoPullRequestsToGitea({
|
|||||||
!config.githubConfig?.token ||
|
!config.githubConfig?.token ||
|
||||||
!config.giteaConfig?.token ||
|
!config.giteaConfig?.token ||
|
||||||
!config.giteaConfig?.url ||
|
!config.giteaConfig?.url ||
|
||||||
!config.giteaConfig?.username
|
!config.giteaConfig?.defaultOwner
|
||||||
) {
|
) {
|
||||||
throw new Error("Missing GitHub or Gitea configuration.");
|
throw new Error("Missing GitHub or Gitea configuration.");
|
||||||
}
|
}
|
||||||
@@ -1458,6 +1526,12 @@ export async function mirrorGitRepoPullRequestsToGitea({
|
|||||||
// Decrypt config tokens for API usage
|
// Decrypt config tokens for API usage
|
||||||
const decryptedConfig = decryptConfigTokens(config as Config);
|
const decryptedConfig = decryptConfigTokens(config as Config);
|
||||||
|
|
||||||
|
// Log configuration details for debugging
|
||||||
|
console.log(`[Pull Requests] Starting PR mirroring for repository ${repository.name}`);
|
||||||
|
console.log(`[Pull Requests] Gitea URL: ${config.giteaConfig!.url}`);
|
||||||
|
console.log(`[Pull Requests] Gitea Owner: ${giteaOwner}`);
|
||||||
|
console.log(`[Pull Requests] Gitea Default Owner: ${config.giteaConfig!.defaultOwner}`);
|
||||||
|
|
||||||
// Verify the repository exists in Gitea before attempting to mirror metadata
|
// Verify the repository exists in Gitea before attempting to mirror metadata
|
||||||
console.log(`[Pull Requests] Verifying repository ${repository.name} exists at ${giteaOwner}`);
|
console.log(`[Pull Requests] Verifying repository ${repository.name} exists at ${giteaOwner}`);
|
||||||
const repoExists = await isRepoPresentInGitea({
|
const repoExists = await isRepoPresentInGitea({
|
||||||
|
|||||||
Reference in New Issue
Block a user