Show More
@@ -37,6 +37,7 b' class PullRequestEvent(RepoEvent):' | |||
|
37 | 37 | self.pullrequest = pullrequest |
|
38 | 38 | |
|
39 | 39 | def as_dict(self): |
|
40 | from rhodecode.lib.utils2 import md5_safe | |
|
40 | 41 | from rhodecode.model.pull_request import PullRequestModel |
|
41 | 42 | data = super(PullRequestEvent, self).as_dict() |
|
42 | 43 | |
@@ -46,6 +47,9 b' class PullRequestEvent(RepoEvent):' | |||
|
46 | 47 | repos=[self.pullrequest.source_repo] |
|
47 | 48 | ) |
|
48 | 49 | issues = _issues_as_dict(commits) |
|
50 | # calculate hashes of all commits for unique identifier of commits | |
|
51 | # inside that pull request | |
|
52 | commits_hash = md5_safe(':'.join(x.get('raw_id', '') for x in commits)) | |
|
49 | 53 | |
|
50 | 54 | data.update({ |
|
51 | 55 | 'pullrequest': { |
@@ -59,6 +63,7 b' class PullRequestEvent(RepoEvent):' | |||
|
59 | 63 | 'shadow_url': PullRequestModel().get_shadow_clone_url( |
|
60 | 64 | self.pullrequest, request=self.request), |
|
61 | 65 | 'status': self.pullrequest.calculated_review_status(), |
|
66 | 'commits_uid': commits_hash, | |
|
62 | 67 | 'commits': commits, |
|
63 | 68 | } |
|
64 | 69 | }) |
@@ -135,8 +135,11 b' WEBHOOK_URL_VARS = [' | |||
|
135 | 135 | |
|
136 | 136 | # pr events vars |
|
137 | 137 | ('pull_request_id', 'Unique ID of the pull request.'), |
|
138 | ('pull_request_title', 'Title of the pull request.'), | |
|
138 | 139 | ('pull_request_url', 'Pull request url.'), |
|
139 | 140 | ('pull_request_shadow_url', 'Pull request shadow repo clone url.'), |
|
141 | ('pull_request_commits_uid', 'Calculated UID of all commits inside the PR. ' | |
|
142 | 'Changes after PR update'), | |
|
140 | 143 | |
|
141 | 144 | # user who triggers the call |
|
142 | 145 | ('username', 'User who triggered the call.'), |
@@ -244,8 +247,11 b' class WebhookDataHandler(object):' | |||
|
244 | 247 | 'register %s call(%s) to url %s', self.name, event, url) |
|
245 | 248 | url = string.Template(url).safe_substitute( |
|
246 | 249 | pull_request_id=data['pullrequest']['pull_request_id'], |
|
250 | pull_request_title=data['pullrequest']['title'], | |
|
247 | 251 | pull_request_url=data['pullrequest']['url'], |
|
248 |
pull_request_shadow_url=data['pullrequest']['shadow_url'], |
|
|
252 | pull_request_shadow_url=data['pullrequest']['shadow_url'], | |
|
253 | pull_request_commits_uid=data['pullrequest']['commits_uid'], | |
|
254 | ) | |
|
249 | 255 | return [(url, self.headers, data)] |
|
250 | 256 | |
|
251 | 257 | def __call__(self, event, data): |
@@ -86,6 +86,8 b' def test_webook_parse_url_for_pull_reque' | |||
|
86 | 86 | base_data['pullrequest'] = { |
|
87 | 87 | 'pull_request_id': 999, |
|
88 | 88 | 'url': 'http://pr-url.com', |
|
89 | 'title': 'example-pr-title', | |
|
90 | 'commits_uid': 'abcdefg1234', | |
|
89 | 91 | 'shadow_url': 'http://pr-url.com/repository' |
|
90 | 92 | } |
|
91 | 93 | headers = {'exmaple-header': 'header-values'} |
General Comments 0
You need to be logged in to leave comments.
Login now