missions api2 gitea
This commit is contained in:
parent
a33048ccf6
commit
4aaf4e8016
@ -141,28 +141,36 @@ export class IntegrationService {
|
||||
await new Promise(resolve => setTimeout(resolve, 3000));
|
||||
|
||||
// Step 4: Create Gitea repository (Consider this non-critical)
|
||||
try {
|
||||
console.log('Starting Gitea repository creation...');
|
||||
const repoData = await this.giteaService.createRepository(mission);
|
||||
if (repoData && repoData.html_url) {
|
||||
giteaRepositoryUrl = repoData.html_url;
|
||||
} else {
|
||||
giteaRepositoryUrl = this.giteaService.getRepositoryUrl(
|
||||
mission.name
|
||||
.toLowerCase()
|
||||
.replace(/\s+/g, '-')
|
||||
.replace(/[^a-z0-9-]/g, '')
|
||||
);
|
||||
// Only create if Gite or Calcul services are selected
|
||||
if (mission.services &&
|
||||
(mission.services.includes('Gite') || mission.services.includes('Calcul'))) {
|
||||
try {
|
||||
console.log('Starting Gitea repository creation...');
|
||||
const repoData = await this.giteaService.createRepository(mission);
|
||||
if (repoData && repoData.html_url) {
|
||||
giteaRepositoryUrl = repoData.html_url;
|
||||
} else {
|
||||
giteaRepositoryUrl = this.giteaService.getRepositoryUrl(
|
||||
mission.name
|
||||
.toLowerCase()
|
||||
.replace(/\s+/g, '-')
|
||||
.replace(/[^a-z0-9-]/g, '')
|
||||
);
|
||||
}
|
||||
console.log(`Gitea repository created at: ${giteaRepositoryUrl}`);
|
||||
integrationStatus.gitea.success = true;
|
||||
integrationStatus.gitea.url = giteaRepositoryUrl;
|
||||
} catch (giteaError) {
|
||||
console.error('Error creating Gitea repository:', giteaError);
|
||||
integrationStatus.gitea.success = false;
|
||||
integrationStatus.gitea.error = giteaError instanceof Error ? giteaError.message : String(giteaError);
|
||||
|
||||
// Don't set criticalFailure - Gitea is non-critical
|
||||
}
|
||||
console.log(`Gitea repository created at: ${giteaRepositoryUrl}`);
|
||||
integrationStatus.gitea.success = true;
|
||||
integrationStatus.gitea.url = giteaRepositoryUrl;
|
||||
} catch (giteaError) {
|
||||
console.error('Error creating Gitea repository:', giteaError);
|
||||
} else {
|
||||
console.log('Skipping Gitea repository creation - neither Gite nor Calcul services selected');
|
||||
integrationStatus.gitea.success = false;
|
||||
integrationStatus.gitea.error = giteaError instanceof Error ? giteaError.message : String(giteaError);
|
||||
|
||||
// Don't set criticalFailure - Gitea is non-critical
|
||||
integrationStatus.gitea.error = 'Skipped - service not selected';
|
||||
}
|
||||
|
||||
// Update the mission with the integration IDs (only for successful integrations)
|
||||
@ -300,17 +308,26 @@ export class IntegrationService {
|
||||
try {
|
||||
// Extract owner and repo from URL
|
||||
const urlParts = giteaRepositoryUrl.split('/');
|
||||
const owner = urlParts[urlParts.length - 2];
|
||||
const repo = urlParts[urlParts.length - 1];
|
||||
|
||||
console.log(`Attempting to delete Gitea repository: ${owner}/${repo}`);
|
||||
const giteaSuccess = await this.giteaService.deleteRepository(owner, repo);
|
||||
rollbackStatuses.gitea = giteaSuccess;
|
||||
console.log(`Gitea repository deletion ${giteaSuccess ? 'successful' : 'failed'}: ${owner}/${repo}`);
|
||||
// Make sure we have enough parts in the URL before accessing array elements
|
||||
if (urlParts.length >= 2) {
|
||||
const owner = urlParts[urlParts.length - 2];
|
||||
const repo = urlParts[urlParts.length - 1];
|
||||
|
||||
console.log(`Attempting to delete Gitea repository: ${owner}/${repo}`);
|
||||
const giteaSuccess = await this.giteaService.deleteRepository(owner, repo);
|
||||
rollbackStatuses.gitea = giteaSuccess;
|
||||
console.log(`Gitea repository deletion ${giteaSuccess ? 'successful' : 'failed'}: ${owner}/${repo}`);
|
||||
} else {
|
||||
console.log(`Invalid Gitea repository URL format: ${giteaRepositoryUrl}`);
|
||||
}
|
||||
} catch (giteaError) {
|
||||
console.error('Error during Gitea rollback:', giteaError);
|
||||
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user