missions api2 gitea

This commit is contained in:
alma 2025-05-06 19:31:42 +02:00
parent a33048ccf6
commit 4aaf4e8016

View File

@ -141,6 +141,9 @@ export class IntegrationService {
await new Promise(resolve => setTimeout(resolve, 3000)); await new Promise(resolve => setTimeout(resolve, 3000));
// Step 4: Create Gitea repository (Consider this non-critical) // Step 4: Create Gitea repository (Consider this non-critical)
// Only create if Gite or Calcul services are selected
if (mission.services &&
(mission.services.includes('Gite') || mission.services.includes('Calcul'))) {
try { try {
console.log('Starting Gitea repository creation...'); console.log('Starting Gitea repository creation...');
const repoData = await this.giteaService.createRepository(mission); const repoData = await this.giteaService.createRepository(mission);
@ -164,6 +167,11 @@ export class IntegrationService {
// Don't set criticalFailure - Gitea is non-critical // Don't set criticalFailure - Gitea is non-critical
} }
} else {
console.log('Skipping Gitea repository creation - neither Gite nor Calcul services selected');
integrationStatus.gitea.success = false;
integrationStatus.gitea.error = 'Skipped - service not selected';
}
// Update the mission with the integration IDs (only for successful integrations) // Update the mission with the integration IDs (only for successful integrations)
await prisma.mission.update({ await prisma.mission.update({
@ -300,6 +308,8 @@ export class IntegrationService {
try { try {
// Extract owner and repo from URL // Extract owner and repo from URL
const urlParts = giteaRepositoryUrl.split('/'); const urlParts = giteaRepositoryUrl.split('/');
// Make sure we have enough parts in the URL before accessing array elements
if (urlParts.length >= 2) {
const owner = urlParts[urlParts.length - 2]; const owner = urlParts[urlParts.length - 2];
const repo = urlParts[urlParts.length - 1]; const repo = urlParts[urlParts.length - 1];
@ -307,10 +317,17 @@ export class IntegrationService {
const giteaSuccess = await this.giteaService.deleteRepository(owner, repo); const giteaSuccess = await this.giteaService.deleteRepository(owner, repo);
rollbackStatuses.gitea = giteaSuccess; rollbackStatuses.gitea = giteaSuccess;
console.log(`Gitea repository deletion ${giteaSuccess ? 'successful' : 'failed'}: ${owner}/${repo}`); console.log(`Gitea repository deletion ${giteaSuccess ? 'successful' : 'failed'}: ${owner}/${repo}`);
} else {
console.log(`Invalid Gitea repository URL format: ${giteaRepositoryUrl}`);
}
} catch (giteaError) { } catch (giteaError) {
console.error('Error during Gitea rollback:', giteaError); console.error('Error during Gitea rollback:', giteaError);
console.log(`⚠️ Note: Gitea repository at ${giteaRepositoryUrl} may need to be deleted manually`); console.log(`⚠️ Note: Gitea repository at ${giteaRepositoryUrl} may need to be deleted manually`);
} }
} else {
console.log('No Gitea repository was created, skipping rollback');
// Mark as successful since there's nothing to delete
rollbackStatuses.gitea = true;
} }
// Provide a summary of rollback operations // Provide a summary of rollback operations