[gitlab] Add PRComment classes and GitLab support for bot: help command#376
Open
sondrebr wants to merge 11 commits into
Open
[gitlab] Add PRComment classes and GitLab support for bot: help command#376sondrebr wants to merge 11 commits into
bot: help command#376sondrebr wants to merge 11 commits into
Conversation
'notable' should be 'noteable'
Some docstrings already referred to subclasses of BaseEventInfo as EventInfo without EventInfo actually being defined anywhere
Commands might for example be supported on GitHub, but not GitLab. Responding with a message explicitly stating that the command is unsupported is more useful to the user than letting the command handler run until it fails.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Another step in implementing GitLab support for the bot, most notably making it support the
bot: helpcommand. Changes include:tools/pr_comments.py:PRCommentclass renamed toPRCommentInfoBasePRCommentclass, "interface" to implement for each Git hosting platform to support creating/getting/editing PR commentsGitHubPRCommentclass, GitHub implementation ofBasePRCommentGitLabPRCommentclass, GitLab implementation ofBasePRCommentcreate_pr_comment_instance()function creating an instance of the correctPRCommentclasscreate_comment()function to use thePRCommentclassestools/commands.py:ALL_COMMANDSconstant (list containing all existing bot commands)SUPPORTED_COMMANDS_PER_GIT_HOSTconstant (dictionary listing supported/implemented commands per Git hosting platform)get_supported_commands()function retrieving the supported commands for the configured Git hosting platformeessi_bot_event_handler.py:handle_issue_comment_event()method to use the EventInfo properties andget_app_name()handle_note_event = handle_issue_comment_eventto make the bot process GitLab commentshandle_bot_command()method to check if command is supported on the configured Git hosting platformbot: helpresponse message to include a list of unsupported commands (if any)get_app_name()totools/git.pyto get the app/bot name (separate settings for GitHub/GitLab)notable_typeinstead ofnoteable_type🤦)Usage
To use the bot in its current state on GitLab, follow the Usage section in the description of #370, except:
514bdf6...is installed.apiscope and the Reporter role (not Planner!) for the bot to be able to post comments.GITLAB_WEBHOOK_SECRET_TOKENenvironment variable. Make sure to include thewhsec_prefix.whsec_. These can be generated e.g. by runningpython -c "import base64, secrets; print('whsec_' + base64.b64encode(secrets.token_bytes(32)).decode())".