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