Enabling webhooks to close review-requests after commits
Review Request #9585 — Created Feb. 4, 2018 and updated — Latest diff uploaded
Review request for feature of rb-gateway to support webhooks on git events. The workflow is
1) Once rb-gateway runs, it installs hookscripts in the repos' it manages. It will install the hookscript under:path/to/repo/.git/hooks/<event-type>.d/99-rb-gateway.sh
in addition to a<event-type>
script underpath/to/repo/.git/hooks/
that runs any pre-existing<event-type>
scripts in the repo. We only support thepost-commit
event for now.
2) Make a commit in the repo hosted on rb-gateway. This will run the hookscript installed in Step 1
3) Hookscript will run which will pipe the commit data from Step 2 to rb-gateway and rb-gateway will make an HTTP request to the reviewboard instance (assuming this is properly configured inconfig.json
)
4) Reviewboard will receive this HTTP request, and close the corresponding reviewBetween the first diff and the latest one, there's been a lot of file movement since I was working off a patch link r/9402 but there was a non-trivial rewrite of rb-gateway in between on master.
Changes include:
1) Updating README on how to run rbgateway
2) Adding API calls for changing the config through http requests rather than having to change the file itself(i.e.DeleteWebhook
DisableWebhook
RegisterWebhook
)
3) Default hookscripts included in rb-gateway, rb-gateway will automatically install them based on ./config/post-commit.sh (or whatever future event-type we will support)
4) Rb-gateway sending an HTTPPOST
to the webhook urlsCorresponding review for reviewboard side of the code:
https://reviews.reviewboard.org/r/9700/
Ran tests
Manual test:
1) Make review request on locally running reviewboard instance of repo rb-gateway will be managing
2) Run rb-gateway with config pointing to a local repo and a webhook
3) Make commit in local repoReview request in Step 1 is closed after Step 3 has completed.
Diff Revision 8
This is not the most recent revision of the diff. The latest diff is revision 13. See what's changed.
.gitignore | ||
Gopkg.lock | ||
Gopkg.toml | ||
README.md | ||
git_repository_test.go | Deleted | |
main.go | ||
main_test.go | Deleted | |
routes_test.go | Deleted | |
sample_config.json | ||
util.go | Deleted | |
util_test.go | Deleted | |
api/api.go | ||
api/auth.go Was auth.go | ||
api/middleware.go | ||
api/routes.go Was routes.go | ||
api/routes_test.go | ||
api/session.go Was session.go | ||
config/config.go | ||
config/config_test.go | ||
helpers/config_helpers.go | ||
helpers/repo_helpers.go | ||
hooks/webhook.go | ||
hookscripts/post-commit.sh | ||
repositories/git.go Was git_repository.go | ||
repositories/git_test.go | ||
repositories/repository.go Was repository.go |
.gitignore |
---|
Gopkg.lock |
---|
Gopkg.toml |
---|
README.md |
---|
git_repository_test.go |
---|
main.go |
---|
main_test.go |
---|
routes_test.go |
---|
sample_config.json |
---|
util.go |
---|
util_test.go |
---|
api/api.go |
---|
auth.go |
---|
api/middleware.go |
---|
routes.go |
---|
api/routes_test.go |
---|
session.go |
---|
config/config.go |
---|
config/config_test.go |
---|
helpers/config_helpers.go |
---|
helpers/repo_helpers.go |
---|
hooks/webhook.go |
---|
hookscripts/post-commit.sh |
---|
git_repository.go |
---|
repositories/git_test.go |
---|
repository.go |
---|