From f5d9d5bae41bb94d12320974c717d5476161adb3 Mon Sep 17 00:00:00 2001 From: Matthew Elderhorst Date: Fri, 3 Nov 2023 10:54:20 +0100 Subject: [PATCH] fix: hasspecifichook function --- src/tasks/gitea/gitea.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/tasks/gitea/gitea.ts b/src/tasks/gitea/gitea.ts index 42dba6a1..d6cee262 100644 --- a/src/tasks/gitea/gitea.ts +++ b/src/tasks/gitea/gitea.ts @@ -77,15 +77,14 @@ async function hasSpecificHook(repoApi: RepositoryApi, hookToFind: string): Prom () => repoApi.repoListHooks(orgName, 'values'), 400, ) - if (hooks) { - hooks.forEach((hook) => { - if (hook.config && hook.config.url.includes(hookToFind)) { - console.debug(`Hook (${hookToFind}) exists`) - console.debug('HOOK:', hook) - return { id: hook.id, hasHook: true } - } - return { hasHook: false } - }) + if (!hooks) return { hasHook: false } + const foundHook = hooks.find((hook) => { + return hook.config && hook.config.url.includes(hookToFind) + }) + if (foundHook) { + console.debug(`Hook (${hookToFind}) exists`) + console.debug('HOOK:', foundHook) + return { id: foundHook.id, hasHook: true } } return { hasHook: false } }