Add dispatcher support for project webhooks#387
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.x #387 +/- ##
==========================================
+ Coverage 93.07% 93.30% +0.23%
==========================================
Files 1 1
Lines 231 239 +8
==========================================
+ Hits 215 223 +8
Misses 11 11
Partials 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds full dispatcher support for *gitlab.ProjectWebhookEvent, which was already parseable by the upstream GitLab Go client but could not be routed by this project's dispatcher (returning ErrUnsupportedEvent). It follows the standard workflow documented in CONTRIBUTING.md for adding a new webhook event.
Changes:
- Added
ProjectListener/OnProjectinterface and all dispatcher wiring (projectListenersslice,RegisterProjectListener,RegisterListenersbranch,Dispatchswitch case,processProjectEvent) - Added
testdata/webhooks/project.jsonfixture with aproject_createpayload - Extended
dispatcher_test.gowith the"project"table entry,ProjectListenerinterface compliance check, andOnProjecthandler asserting key fields
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
listeners.go |
Adds ProjectListener interface with OnProject method, correctly positioned in alphabetical order |
dispatcher.go |
Adds all five dispatcher integration points: listener slice, RegisterProjectListener, RegisterListeners type-check, Dispatch switch case, and processProjectEvent handler |
dispatcher_test.go |
Adds test table entry, interface compliance assertion, and OnProject method asserting Name and PathWithNamespace from the fixture |
testdata/webhooks/project.json |
Minimal valid project_create payload with "name": "Flight" and "path_with_namespace": "flightjs/flight" matching test assertions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Project webhook events were parsed by the upstream client but not routed by this dispatcher, so
ProjectWebhookEventpayloads returnedErrUnsupportedEventand listeners never ran.ProjectListener/OnProjectinterface, dispatcher slice/registration, dispatch switch branch, and handler to process*gitlab.ProjectWebhookEvent.testdata/webhooks/project.jsonand extended dispatcher tests to assert project webhooks dispatch and invoke listeners.Example:
Original prompt