mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2025-12-30 19:48:09 +03:00
updates
This commit is contained in:
@@ -53,6 +53,7 @@ export const giteaConfigSchema = z.object({
|
||||
.default("reference"),
|
||||
// Mirror options
|
||||
mirrorReleases: z.boolean().default(false),
|
||||
releaseLimit: z.number().default(10),
|
||||
mirrorMetadata: z.boolean().default(false),
|
||||
mirrorIssues: z.boolean().default(false),
|
||||
mirrorPullRequests: z.boolean().default(false),
|
||||
|
||||
@@ -1399,12 +1399,16 @@ export async function mirrorGitHubReleasesToGitea({
|
||||
throw new Error(`Repository ${repository.name} does not exist in Gitea at ${repoOwner}. Please ensure the repository is mirrored first.`);
|
||||
}
|
||||
|
||||
// Get release limit from config (default to 10)
|
||||
const releaseLimit = config.giteaConfig?.releaseLimit || 10;
|
||||
|
||||
const releases = await octokit.rest.repos.listReleases({
|
||||
owner: repository.owner,
|
||||
repo: repository.name,
|
||||
per_page: releaseLimit, // Only fetch the latest N releases
|
||||
});
|
||||
|
||||
console.log(`[Releases] Found ${releases.data.length} releases to mirror for ${repository.fullName}`);
|
||||
console.log(`[Releases] Found ${releases.data.length} releases (limited to latest ${releaseLimit}) to mirror for ${repository.fullName}`);
|
||||
|
||||
if (releases.data.length === 0) {
|
||||
console.log(`[Releases] No releases to mirror for ${repository.fullName}`);
|
||||
@@ -1414,7 +1418,12 @@ export async function mirrorGitHubReleasesToGitea({
|
||||
let mirroredCount = 0;
|
||||
let skippedCount = 0;
|
||||
|
||||
for (const release of releases.data) {
|
||||
// Sort releases by created_at to ensure we get the most recent ones
|
||||
const sortedReleases = releases.data.sort((a, b) =>
|
||||
new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
|
||||
).slice(0, releaseLimit);
|
||||
|
||||
for (const release of sortedReleases) {
|
||||
try {
|
||||
// Check if release already exists
|
||||
const existingReleasesResponse = await httpGet(
|
||||
|
||||
@@ -89,6 +89,7 @@ export function mapUiToDbConfig(
|
||||
|
||||
// Mirror options from UI
|
||||
mirrorReleases: mirrorOptions.mirrorReleases,
|
||||
releaseLimit: mirrorOptions.releaseLimit || 10,
|
||||
mirrorMetadata: mirrorOptions.mirrorMetadata,
|
||||
mirrorIssues: mirrorOptions.mirrorMetadata && mirrorOptions.metadataComponents.issues,
|
||||
mirrorPullRequests: mirrorOptions.mirrorMetadata && mirrorOptions.metadataComponents.pullRequests,
|
||||
@@ -135,6 +136,7 @@ export function mapDbToUiConfig(dbConfig: any): {
|
||||
// Map mirror options from various database fields
|
||||
const mirrorOptions: MirrorOptions = {
|
||||
mirrorReleases: dbConfig.giteaConfig?.mirrorReleases || false,
|
||||
releaseLimit: dbConfig.giteaConfig?.releaseLimit || 10,
|
||||
mirrorLFS: dbConfig.giteaConfig?.lfs || false,
|
||||
mirrorMetadata: dbConfig.giteaConfig?.mirrorMetadata || false,
|
||||
metadataComponents: {
|
||||
|
||||
Reference in New Issue
Block a user