-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add EventType consts representing the X-Github-Event header values #3272
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @MaerF0x0!
Two minor tweaks, please, then we should be ready for a second LGTM+Approval from any other contributor to this repo before merging.
Also, please make sure all tests run locally by following step 4 of CONTRIBUTING.md and push any necessary changes to this PR. |
Also, please resolve all conflicts and push (not force-push) the changes to this PR. Thank you! |
@gmlewis Thanks for the updates. I will be able to get to this in the later half of October. Just wanted you to know I haven't forgotten about, or abandoned this :) |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3272 +/- ##
==========================================
- Coverage 97.72% 93.01% -4.71%
==========================================
Files 153 172 +19
Lines 13390 14848 +1458
==========================================
+ Hits 13085 13811 +726
- Misses 215 944 +729
- Partials 90 93 +3 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @MaerF0x0 !
I just did a quick search for a random event string in the code base, like so:
$ rg code_scanning_alert
github/repos_hooks_deliveries_test.go
148: "code_scanning_alert": &CodeScanningAlertEvent{},
github/messages_test.go
281: messageType: "code_scanning_alert",
github/messages.go
52: "code_scanning_alert": &CodeScanningAlertEvent{},
github/orgs_audit_log_test.go
45: "events": ["code_scanning_alert"],
143: "events": []interface{}{"code_scanning_alert"},
github/event_types.go
1866:// GitHub API docs: https://docs.github.com/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#code_scanning_alert
and noticed that github/messages_test.go
still spells out all of these constants explicitly, which seems odd.
I'm just thinking about when the next event gets added, the developer experience of copying that string multiple places is still not fully solved.
I think the other locations are probably fine, but messages_test.go
should probably be updated as well.
Thoughts?
What: Adds
type EventType string
and anEventType
const for every of the types in the maps ingithub/messages.go
Why: So that we can do switches like
Notes:
type EventTyper interface{}
on each of those structs