This repository was archived by the owner on Sep 30, 2024. It is now read-only.
webhooks: Handle GitLab push events#45856
Merged
Merged
Conversation
Contributor
|
Codenotify: Notifying subscribers in CODENOTIFY files for diff 1d57a50...8fd469b.
|
So that it doesn't need to take unnecessary params.
ryanslade
commented
Dec 20, 2022
| } | ||
|
|
||
| func (g *GitHubWebhookHandler) handleGitHubWebhook(ctx context.Context, _ database.DB, _ extsvc.CodeHostBaseURL, payload any) error { | ||
| func (g *GitHubWebhookHandler) handle(ctx context.Context, payload any) error { |
Contributor
Author
There was a problem hiding this comment.
Simplified to not take unused params.
pjlast
reviewed
Dec 20, 2022
pjlast
reviewed
Dec 20, 2022
pjlast
approved these changes
Dec 20, 2022
pjlast
left a comment
Contributor
There was a problem hiding this comment.
Looks good 🕸️ 🪝 🥳
Just wondering about the way we do URL parsing
sashaostrikov
approved these changes
Dec 21, 2022
mrnugget
approved these changes
Dec 21, 2022
| } | ||
|
|
||
| func (g *GitHubWebhookHandler) handleGitHubWebhook(ctx context.Context, _ database.DB, _ extsvc.CodeHostBaseURL, payload any) error { | ||
| func (g *GitHubWebhookHandler) handle(ctx context.Context, payload any) error { |
Contributor
There was a problem hiding this comment.
This confused me in other parts of the code too: handle is awfully generic but inside it makes assumptions about the event type it's called for. So I think it's easier to understand when encoded in name
Suggested change
| func (g *GitHubWebhookHandler) handle(ctx context.Context, payload any) error { | |
| func (g *GitHubWebhookHandler) handlePush(ctx context.Context, payload any) error { |
| repoName, err := githubNameFromEvent(event) | ||
| if err != nil { | ||
| return errors.Wrap(err, "handleGitHubWebhook: get name failed") | ||
| return errors.Wrap(err, "handle: get name failed") |
Contributor
There was a problem hiding this comment.
See above: handle doesn't add anything really useful, I think.
| } | ||
| } | ||
|
|
||
| func (g *GitLabWebhookHandler) handle(ctx context.Context, payload any) error { |
Contributor
There was a problem hiding this comment.
Same as above
Suggested change
| func (g *GitLabWebhookHandler) handle(ctx context.Context, payload any) error { | |
| func (g *GitLabWebhookHandler) handlePushEvent(ctx context.Context, payload any) error { |
sashaostrikov
approved these changes
Dec 21, 2022
sashaostrikov
left a comment
Contributor
There was a problem hiding this comment.
LGTM! Added a typo fix and test name suggestions
…_handler_test.go Co-authored-by: Alex Ostrikov <alex.ostrikov@sourcegraph.com>
…_handler_test.go Co-authored-by: Alex Ostrikov <alex.ostrikov@sourcegraph.com>
…_handler.go Co-authored-by: Alex Ostrikov <alex.ostrikov@sourcegraph.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


This change adds support to handle incoming
pushwebhooks from GitLab.Closes #45762
Test plan
Tests added and manually tested the full flow of pushing to a repo and seeing it update locally.