Project

General

Profile

Actions

Feature #5583

open

rcextensions hook for pull request comment

Added by Olivier Renaud almost 5 years ago. Updated over 4 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
-
Target version:
Start date:
18.01.2020
Due date:
% Done:

0%

Estimated time:
Sorting:
Commit Number:

Description

There is no hook in rcextensions for when a comment is added on a pull request. I need that hook, because I am writing a bot and I would like users to be able to send commands to this bot using comments. For example, a user would add a comment "@buildbot trigger", and the rcextensions hook would send a request to our CI server.

The closest hook available is _review_pull_request_hook, but it's only when a comment of a reviewer changes the status through a comment.

Interestingly, webhooks can already react on new comments when the box "pullrequest commented" is checked. I don't see a way to reference the content of the comment though, so it does not seems very useful.

Actions #1

Updated by Olivier Renaud almost 5 years ago

I found a workaround. It relies on adding a sqlalchemy hook in rcextensions.

from rhodecode.model.db import ChangesetComment
import sqlalchemy

@sqlalchemy.event.listens_for(ChangesetComment, 'after_insert')
def react_on_comment(_mapper, _connection, comment):
    text = comment.text
    author = comment.author.username
    pr = comment.pull_request
    # do cool things here
Actions #2

Updated by Daniel D over 4 years ago

  • Status changed from New to In Progress
  • Target version set to v4.19

We're adding this properly to rcextensions now.

Actions #3

Updated by Daniel D over 4 years ago

We've built a proper rcextensions logic for this now. Thanks for this ticket, it really helped us understand this case, and even now internally we're coding some "chat-ops" style logic for sending commands via comments. I've added an example here how to do some trigger based on comment text:

https://code.rhodecode.com/rhodecode-enterprise-ce/files/de8db8daf7bb52e1ee8c00f5a353634686074a25/rhodecode/config/rcextensions/examples/trigger_ci_call_on_comment.py

We'll also now do an extension on top of integrations logic to support those two new cases of comment_on_commit, and comment_on_pull_request !

Best,

Actions #4

Updated by Redmine Integration over 4 years ago

  • Status changed from In Progress to Resolved
Actions #5

Updated by Olivier Renaud over 4 years ago

This looks great ! Thanks !

Actions

Also available in: Atom PDF