Add per-repo config and prepare for org-wide webhook #9
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 PR contains multiple refactors to allow other teams to easily add triagebot on their own repositories, and to reduce the maintenance overhead on our end.
Each repository now has its own configuration file,
triagebot.toml
, which lives at the root of the master branch that repository, and it's fetched by triagebot at runtime whenever needed (and cached for 2 minutes). If a repository doesn't have the configuration file and an user tries to execute a valid command an error will be shown in the comments instead.Each of the handlers has its own section in the configuration file, and triagebot will call the handler only if the configuration section is present, allowing repository owners to toggle the handlers they want on their end. As with disabled repos, if an user tries to use a disabled handler an error will be shown.
The way handlers are registered in the code changed: instead of using dynamic dispatch they have to be registered in a macro in
handlers.rs
(which replaces themod foo;
). This way it's possible to automatically disable not configured handlers, and associated types can be used in the trait.The trait also changed, with
handle_event
being split into two methods (parse_input
andhandle_input
). This way the input is also parsed when the handler is disabled, allowing the code to show the disabled handler error message only when a valid command was actually present in the comment.Finally I did some bits of cleanup in the code, and renamed the
label
handler inrelabel
since that's what it actually does.r? @Mark-Simulacrum
Before deploying this PR, the following
triagebot.toml
must be landed in the rustc repo: