##// END OF EJS Templates
webhook: enable support of extra repo variables as replacement in template url.
marcink -
r1761:8612110c default
parent child Browse files
Show More
@@ -16,6 +16,7 b''
16 16 # RhodeCode Enterprise Edition, including its added features, Support services,
17 17 # and proprietary license terms, please see https://rhodecode.com/licenses/
18 18
19 import collections
19 20 import logging
20 21
21 22 from rhodecode.translation import lazy_ugettext
@@ -75,9 +76,10 b' def _commits_as_dict(commit_ids, repos):'
75 76 urlified_message, issues_data = process_patterns(
76 77 cs_data['message'], repo.repo_name)
77 78 cs_data['issues'] = issues_data
78 cs_data['message_html'] = urlify_commit_message(cs_data['message'],
79 repo.repo_name)
80 cs_data['message_html_title'] = chop_at_smart(cs_data['message'], '\n', suffix_if_chopped='...')
79 cs_data['message_html'] = urlify_commit_message(
80 cs_data['message'], repo.repo_name)
81 cs_data['message_html_title'] = chop_at_smart(
82 cs_data['message'], '\n', suffix_if_chopped='...')
81 83 commits.append(cs_data)
82 84
83 85 needed_commits.remove(commit_id)
@@ -118,12 +120,17 b' class RepoEvent(RhodecodeEvent):'
118 120 def as_dict(self):
119 121 from rhodecode.model.repo import RepoModel
120 122 data = super(RepoEvent, self).as_dict()
123 extra_fields = collections.OrderedDict()
124 for field in self.repo.extra_fields:
125 extra_fields[field.field_key] = field.field_value
126
121 127 data.update({
122 128 'repo': {
123 129 'repo_id': self.repo.repo_id,
124 130 'repo_name': self.repo.repo_name,
125 131 'repo_type': self.repo.repo_type,
126 'url': RepoModel().get_url(self.repo)
132 'url': RepoModel().get_url(self.repo),
133 'extra_fields': extra_fields
127 134 }
128 135 })
129 136 return data
@@ -41,6 +41,8 b' WEBHOOK_URL_VARS = ['
41 41 'repo_type',
42 42 'repo_id',
43 43 'repo_url',
44 # extra repo fields
45 'extra:<extra_key_name>',
44 46
45 47 # special attrs below that we handle, using multi-call
46 48 'branch',
@@ -77,6 +79,10 b' class WebhookHandler(object):'
77 79 'username': data['actor']['username'],
78 80 'user_id': data['actor']['user_id']
79 81 }
82 extra_vars = {}
83 for extra_key, extra_val in data['repo']['extra_fields'].items():
84 extra_vars['extra:{}'.format(extra_key)] = extra_val
85 common_vars.update(extra_vars)
80 86
81 87 return string.Template(
82 88 self.template_url).safe_substitute(**common_vars)
@@ -33,6 +33,7 b' def base_data():'
33 33 'repo_type': 'hg',
34 34 'repo_id': '12',
35 35 'url': 'http://repo.url/foo',
36 'extra_fields': {},
36 37 },
37 38 'actor': {
38 39 'username': 'actor_name',
General Comments 0
You need to be logged in to leave comments. Login now