FORGE-92: close changesets when a Forgejo branch is deleted #743

Merged
gmackie merged 1 commit from FORGE-92-forgejo-branch-delete into main 2026-10-12 07:54:44 +00:00
Owner

Kanbanger: FORGE-92 (parent FORGE-78). Delivery target: production.

Problem

Forgejo reports a deleted branch with a delete webhook and sends no push. ForgeGraph's per-repo hooks never subscribed to delete, so the push pipeline's close-on-delete path never ran for Forgejo. A deleted branch's changeset stayed open and kept ci_failed alerts firing. Found during FORGE-78 verification: probe changeset bdf391e1 is still open.

Change

  • x-gitea-event: delete with ref_type=branch becomes the same zero-SHA PushEvent the source-neutral pipeline already closes changesets for (forgejoDeleteEvent + handleDelete). Tag deletions are acknowledged and ignored.
  • ensureForgejoWebhook subscribes new hooks to delete. An existing ForgeGraph hook that lacks it is PATCHed to add it; its other events, URL and signing secret are kept, and the result is updated: true. POST /api/fg/repos/:id/webhook now reports updated, so it can backfill existing repos idempotently.

Tests (local lanes green before push; CI is backed up)

  • delete.test.ts: normalization, closing the active changeset with a Kanbanger changeset.closed event, tags ignored, malformed payload gets 400.
  • route.test.ts: delete events are dispatched to the delete handler.
  • forgejo-webhook-events.test.ts: create includes delete; patch adds only delete and leaves the URL and secret alone; no-op when already present; failures reported.
  • The push characterization snapshot is unchanged.
  • Full lanes: web 257 files / 1779 tests, API unit 163 files / 1577 tests. Web and API typecheck clean.

After deploy

  1. Backfill existing hooks with POST /api/fg/repos/:id/webhook across registered repos, and report the count.
  2. Close bdf391e1 by replaying its branch delete through the pipeline.

🤖 Generated with Claude Code

Kanbanger: FORGE-92 (parent FORGE-78). Delivery target: production. ## Problem Forgejo reports a deleted branch with a `delete` webhook and sends no `push`. ForgeGraph's per-repo hooks never subscribed to `delete`, so the push pipeline's close-on-delete path never ran for Forgejo. A deleted branch's changeset stayed open and kept ci_failed alerts firing. Found during FORGE-78 verification: probe changeset `bdf391e1` is still open. ## Change - `x-gitea-event: delete` with `ref_type=branch` becomes the same zero-SHA `PushEvent` the source-neutral pipeline already closes changesets for (`forgejoDeleteEvent` + `handleDelete`). Tag deletions are acknowledged and ignored. - `ensureForgejoWebhook` subscribes new hooks to `delete`. An existing ForgeGraph hook that lacks it is PATCHed to add it; its other events, URL and signing secret are kept, and the result is `updated: true`. `POST /api/fg/repos/:id/webhook` now reports `updated`, so it can backfill existing repos idempotently. ## Tests (local lanes green before push; CI is backed up) - `delete.test.ts`: normalization, closing the active changeset with a Kanbanger `changeset.closed` event, tags ignored, malformed payload gets 400. - `route.test.ts`: `delete` events are dispatched to the delete handler. - `forgejo-webhook-events.test.ts`: create includes `delete`; patch adds only `delete` and leaves the URL and secret alone; no-op when already present; failures reported. - The push characterization snapshot is unchanged. - Full lanes: web 257 files / 1779 tests, API unit 163 files / 1577 tests. Web and API typecheck clean. ## After deploy 1. Backfill existing hooks with `POST /api/fg/repos/:id/webhook` across registered repos, and report the count. 2. Close `bdf391e1` by replaying its branch delete through the pipeline. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
FORGE-92: close changesets when a Forgejo branch is deleted
Some checks failed
CI / superseded (pull_request) Successful in 3s
CI / gitleaks (pull_request) Successful in 17s
CI / go (pull_request) Successful in 1m24s
CI / unit-web (pull_request) Failing after 1m21s
CI / storybook (pull_request) Successful in 1m47s
CI / web-build (pull_request) Successful in 1m57s
CI / database (pull_request) Successful in 2m48s
CI / checks (pull_request) Successful in 3m58s
CI / unit-api (pull_request) Successful in 4m17s
forgegraph/ci CI failed
CI / ci (pull_request) Failing after 46s
CI / database-d1 (pull_request) Failing after 7m12s
fffa4116d8
Forgejo reports a deleted branch with a `delete` webhook and sends no
`push`, and ForgeGraph's per-repo hooks never subscribed to `delete`, so
the push pipeline's close-on-delete path never ran for Forgejo: a deleted
branch's changeset stayed open (and kept ci_failed alerts firing). Found
during FORGE-78 verification.

- The webhook route now handles `x-gitea-event: delete`. A branch deletion
  (ref_type=branch) becomes the same zero-sha PushEvent the pipeline already
  closes active changesets for (forgejoDeleteEvent + handleDelete); tag
  deletions are acknowledged and ignored.
- ensureForgejoWebhook subscribes new hooks to `delete`, and an existing
  ForgeGraph hook that lacks it is PATCHed to add it, keeping its other
  events, URL and signing secret (`updated: true`). POST
  /api/fg/repos/:id/webhook reports `updated`, so it backfills existing
  repos idempotently.

Tests: delete normalization and close path, route dispatch, and the
webhook create / patch / no-op / failure paths. The push characterization
snapshot is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Author
Owner

Preview environment is live: https://pr-743-forgegraph.forgegraf.com

Deployed fffa4116 with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.

Preview environment is live: https://pr-743-forgegraph.forgegraf.com Deployed `fffa4116` with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.
gmackie force-pushed FORGE-92-forgejo-branch-delete from fffa4116d8
Some checks failed
CI / superseded (pull_request) Successful in 3s
CI / gitleaks (pull_request) Successful in 17s
CI / go (pull_request) Successful in 1m24s
CI / unit-web (pull_request) Failing after 1m21s
CI / storybook (pull_request) Successful in 1m47s
CI / web-build (pull_request) Successful in 1m57s
CI / database (pull_request) Successful in 2m48s
CI / checks (pull_request) Successful in 3m58s
CI / unit-api (pull_request) Successful in 4m17s
forgegraph/ci CI failed
CI / ci (pull_request) Failing after 46s
CI / database-d1 (pull_request) Failing after 7m12s
to e66e3c78d1
Some checks failed
CI / superseded (pull_request) Successful in 1s
CF executor smoke / smoke (pull_request) Successful in 20s
CI / gitleaks (pull_request) Successful in 14s
CI / checks (pull_request) Successful in 1m36s
CI / go (pull_request) Successful in 1m56s
CI / database (pull_request) Successful in 2m31s
CI / storybook (pull_request) Successful in 2m34s
CI / unit-api (pull_request) Successful in 2m13s
CI / unit-web (pull_request) Successful in 2m28s
CI / web-build (pull_request) Successful in 4m19s
CI / ci (pull_request) Successful in 43s
CI / database-d1 (pull_request) Failing after 7m8s
2026-10-12 07:36:39 +00:00
Compare
Sign in to join this conversation.
No description provided.