Skip to content

Commit b7047df

Browse files
committed
fix handleInstallationDeleted handler for gitlab
1 parent 823bcf6 commit b7047df

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

integrations/gitlab/src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { fetchProject, fetchProjectBranches, fetchProjects, searchUserProjects }
88
import { configBlock } from './components';
99
import { uninstallWebhook } from './provider';
1010
import { triggerExport, updateCommitWithPreviewLinks } from './sync';
11-
import type { GitLabRuntimeContext } from './types';
11+
import type { GitLabRuntimeContext, GitLabSpaceConfiguration } from './types';
1212
import { getSpaceConfigOrThrow, assertIsDefined, verifySignature } from './utils';
1313
import { handleMergeRequestEvent, handlePushEvent } from './webhooks';
1414

@@ -135,7 +135,7 @@ const handleFetchEvent: FetchEventCallback<GitLabRuntimeContext> = async (reques
135135
const page = pageNumber || 1;
136136
const projects = await fetchProjects(spaceConfig, {
137137
page,
138-
per_page: 1,
138+
per_page: 100,
139139
walkPagination: false,
140140
});
141141

@@ -306,13 +306,13 @@ const handleSpaceInstallationDeleted: EventCallback<
306306
> = async (event, context) => {
307307
logger.debug(`space installation deleted for space ${event.spaceId}, removing webhook`);
308308

309-
const spaceInstallation = context.environment.spaceInstallation;
310-
if (!spaceInstallation) {
311-
logger.debug(`missing space installation, skipping`);
309+
const configuration = event.previous.configuration as GitLabSpaceConfiguration | undefined;
310+
if (!configuration) {
311+
logger.debug(`missing space installation configuration, skipping`);
312312
return;
313313
}
314314

315-
await uninstallWebhook(spaceInstallation);
315+
await uninstallWebhook(configuration);
316316
};
317317

318318
export default createIntegration({

integrations/gitlab/src/provider.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,14 @@ export async function installWebhook(
3737
* Remove the GitLab webhook for the currently configured space installation
3838
* project.
3939
*/
40-
export async function uninstallWebhook(spaceInstallation: IntegrationSpaceInstallation) {
41-
const config = getSpaceConfigOrThrow(spaceInstallation);
42-
43-
if (!config.webhookId) {
44-
return;
45-
}
46-
40+
export async function uninstallWebhook(config: GitLabSpaceConfiguration) {
4741
assertIsDefined(config.project, { label: 'config.project' });
42+
assertIsDefined(config.webhookId, { label: 'config.webhookId' });
4843

4944
const projectId = config.project;
45+
const webhookId = config.webhookId;
5046

51-
await deleteProjectWebhook(config, projectId, config.webhookId);
47+
await deleteProjectWebhook(config, projectId, webhookId);
5248

5349
logger.info(`Webhook ${config.webhookId} uninstalled from GitLab project ${projectId}`);
5450
}

0 commit comments

Comments
 (0)