Show More
@@ -1,175 +1,187 b'' | |||
|
1 |
# This code allows override the integrations templates. |
|
|
2 | # file of rcextensions | |
|
1 | # This code allows override the integrations templates. | |
|
2 | # Put this into the __init__.py file of rcextensions to override the templates | |
|
3 | 3 | |
|
4 | 4 | |
|
5 | ||
|
5 | # EMAIL Integration | |
|
6 | 6 | from rhodecode.integrations import email |
|
7 | 7 | email.REPO_PUSH_TEMPLATE_HTML = email.Template(''' |
|
8 | 8 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
|
9 | 9 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|
10 | 10 | <head> |
|
11 | 11 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|
12 | 12 | <meta name="viewport" content="width=device-width, initial-scale=1.0"/> |
|
13 | 13 | <title>${subject}</title> |
|
14 | 14 | <style type="text/css"> |
|
15 | 15 | /* Based on The MailChimp Reset INLINE: Yes. */ |
|
16 | 16 | #outlook a {padding:0;} /* Force Outlook to provide a "view in browser" menu link. */ |
|
17 | 17 | body{width:100% !important; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%; margin:0; padding:0;} |
|
18 | 18 | /* Prevent Webkit and Windows Mobile platforms from changing default font sizes.*/ |
|
19 | 19 | .ExternalClass {width:100%;} /* Force Hotmail to display emails at full width */ |
|
20 | 20 | .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div {line-height: 100%;} |
|
21 | 21 | /* Forces Hotmail to display normal line spacing. More on that: http://www.emailonacid.com/forum/viewthread/43/ */ |
|
22 | 22 | #backgroundTable {margin:0; padding:0; line-height: 100% !important;} |
|
23 | 23 | /* End reset */ |
|
24 | 24 | |
|
25 | 25 | /* defaults for images*/ |
|
26 | 26 | img {outline:none; text-decoration:none; -ms-interpolation-mode: bicubic;} |
|
27 | 27 | a img {border:none;} |
|
28 | 28 | .image_fix {display:block;} |
|
29 | 29 | |
|
30 | 30 | body {line-height:1.2em;} |
|
31 | 31 | p {margin: 0 0 20px;} |
|
32 | 32 | h1, h2, h3, h4, h5, h6 {color:#323232!important;} |
|
33 | 33 | a {color:#427cc9;text-decoration:none;outline:none;cursor:pointer;} |
|
34 | 34 | a:focus {outline:none;} |
|
35 | 35 | a:hover {color: #305b91;} |
|
36 | 36 | h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {color:#427cc9!important;text-decoration:none!important;} |
|
37 | 37 | h1 a:active, h2 a:active, h3 a:active, h4 a:active, h5 a:active, h6 a:active {color: #305b91!important;} |
|
38 | 38 | h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited {color: #305b91!important;} |
|
39 | 39 | table {font-size:13px;border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt;} |
|
40 | 40 | table td {padding:.65em 1em .65em 0;border-collapse:collapse;vertical-align:top;text-align:left;} |
|
41 | 41 | input {display:inline;border-radius:2px;border-style:solid;border: 1px solid #dbd9da;padding:.5em;} |
|
42 | 42 | input:focus {outline: 1px solid #979797} |
|
43 | 43 | @media only screen and (-webkit-min-device-pixel-ratio: 2) { |
|
44 | 44 | /* Put your iPhone 4g styles in here */ |
|
45 | 45 | } |
|
46 | 46 | |
|
47 | 47 | /* Android targeting */ |
|
48 | 48 | @media only screen and (-webkit-device-pixel-ratio:.75){ |
|
49 | 49 | /* Put CSS for low density (ldpi) Android layouts in here */ |
|
50 | 50 | } |
|
51 | 51 | @media only screen and (-webkit-device-pixel-ratio:1){ |
|
52 | 52 | /* Put CSS for medium density (mdpi) Android layouts in here */ |
|
53 | 53 | } |
|
54 | 54 | @media only screen and (-webkit-device-pixel-ratio:1.5){ |
|
55 | 55 | /* Put CSS for high density (hdpi) Android layouts in here */ |
|
56 | 56 | } |
|
57 | 57 | /* end Android targeting */ |
|
58 | 58 | |
|
59 | 59 | </style> |
|
60 | 60 | |
|
61 | 61 | <!-- Targeting Windows Mobile --> |
|
62 | 62 | <!--[if IEMobile 7]> |
|
63 | 63 | <style type="text/css"> |
|
64 | 64 | |
|
65 | 65 | </style> |
|
66 | 66 | <![endif]--> |
|
67 | 67 | |
|
68 | 68 | <!--[if gte mso 9]> |
|
69 | 69 | <style> |
|
70 | 70 | /* Target Outlook 2007 and 2010 */ |
|
71 | 71 | </style> |
|
72 | 72 | <![endif]--> |
|
73 | 73 | </head> |
|
74 | 74 | <body> |
|
75 | 75 | <!-- Wrapper/Container Table: Use a wrapper table to control the width and the background color consistently of your email. Use this approach instead of setting attributes on the body tag. --> |
|
76 | 76 | <table cellpadding="0" cellspacing="0" border="0" id="backgroundTable" align="left" style="margin:1%;width:97%;padding:0;font-family:sans-serif;font-weight:100;border:1px solid #dbd9da"> |
|
77 | 77 | <tr> |
|
78 | 78 | <td valign="top" style="padding:0;"> |
|
79 | 79 | <table cellpadding="0" cellspacing="0" border="0" align="left" width="100%"> |
|
80 | 80 | <tr><td style="width:100%;padding:7px;background-color:#202020" valign="top"> |
|
81 | 81 | <a style="color:#eeeeee;text-decoration:none;" href="${instance_url}"> |
|
82 | 82 | ${'RhodeCode'} |
|
83 | 83 | </a> |
|
84 | 84 | </td></tr> |
|
85 | 85 | <tr> |
|
86 | 86 | <td style="padding:15px;" valign="top"> |
|
87 | 87 | % if data['push']['commits']: |
|
88 | 88 | % for commit in data['push']['commits']: |
|
89 | 89 | <a href="${commit['url']}">${commit['short_id']}</a> by ${commit['author']} at ${commit['date']} <br/> |
|
90 | 90 | ${commit['message_html']} <br/> |
|
91 | 91 | <br/> |
|
92 | 92 | % endfor |
|
93 | 93 | % else: |
|
94 | 94 | No commit data |
|
95 | 95 | % endif |
|
96 | 96 | </td> |
|
97 | 97 | </tr> |
|
98 | 98 | </table> |
|
99 | 99 | </td> |
|
100 | 100 | </tr> |
|
101 | 101 | </table> |
|
102 | 102 | <!-- End of wrapper table --> |
|
103 | 103 | <p><a style="margin-top:15px;margin-left:1%;font-family:sans-serif;font-weight:100;font-size:11px;color:#666666;text-decoration:none;" href="${instance_url}"> |
|
104 | 104 | ${'This is a notification from RhodeCode. %(instance_url)s' % {'instance_url': instance_url}} |
|
105 | 105 | </a></p> |
|
106 | 106 | </body> |
|
107 | 107 | </html> |
|
108 | 108 | ''') |
|
109 | 109 | |
|
110 | 110 | |
|
111 | # JIRA (EE ONLY) | |
|
111 | # JIRA Integration (EE ONLY) | |
|
112 | # available variables: | |
|
113 | # url, short_id ,author | |
|
114 | # branch, commit_message | |
|
115 | # commit (dict data for commit) | |
|
112 | 116 | from rc_integrations import jira_tracker |
|
113 | 117 | |
|
114 | jira_tracker.COMMENT_TEMPLATE_PULL_REQUEST = jira_tracker.Template(''' | |
|
115 | ${action} by ${author} (status: ${status}). \n | |
|
116 | pull-request: ${url} | |
|
117 | ''') | |
|
118 | ||
|
119 | ||
|
118 | # used for references issues without transition, e.g `This ticket references PROJ-123` | |
|
120 | 119 | jira_tracker.COMMENT_TEMPLATE_COMMIT = jira_tracker.Template(''' |
|
121 | 120 | Commit `${short_id}` by ${author} on `${branch}` branch references this issue. \n |
|
122 | 121 | ${url}\n |
|
123 | 122 | |
|
124 | 123 | ## MODIFICATION add custom COMMIT message to the comment |
|
125 | 124 | ${commit['message']} |
|
126 | 125 | ''') |
|
127 | 126 | |
|
128 | ||
|
127 | # used when there's a transition, e.g referenced issues status goes from | |
|
128 | # open to resolved this is used in correlation with something like `closes PROJ-123` | |
|
129 | 129 | jira_tracker.COMMENT_TEMPLATE_COMMIT_WITH_STATUS = jira_tracker.Template(''' |
|
130 | 130 | Commit `${short_id}` by ${author} on `${branch}` branch changed this issue. \n |
|
131 | 131 | '{url}\n |
|
132 | 132 | |
|
133 | 133 | ## MODIFICATION add custom COMMIT message to the comment |
|
134 | 134 | ${commit['message']} |
|
135 | 135 | ''') |
|
136 | 136 | |
|
137 | jira_tracker.COMMENT_TEMPLATE_PULL_REQUEST = jira_tracker.Template(''' | |
|
138 | ${action} by ${author} (status: ${status}). \n | |
|
139 | pull-request: ${url} | |
|
140 | ''') | |
|
141 | ||
|
137 | 142 | |
|
138 | 143 | # REDMINE (EE ONLY) |
|
144 | # available variables: | |
|
145 | # url, short_id ,author | |
|
146 | # branch, commit_message | |
|
147 | # commit (dict data for commit) | |
|
139 | 148 | from rc_integrations import redmine_tracker |
|
140 | 149 | |
|
150 | # used for references issues without transition, e.g `This ticket references #123` | |
|
141 | 151 | redmine_tracker.COMMENT_TEMPLATE_COMMIT = redmine_tracker.Template(''' |
|
142 | 152 | Commit `${short_id}` by ${author} on `${branch}` branch references this issue. \n |
|
143 | 153 | commit: ${url}\n |
|
144 | 154 | |
|
145 | 155 | ## MODIFICATION add custom COMMIT message to the comment |
|
146 | 156 | message: |
|
147 | 157 | ``` |
|
148 | 158 | ${commit['message']} |
|
149 | 159 | ``` |
|
150 | 160 | |
|
151 | 161 | ''') |
|
152 | 162 | |
|
163 | # used when there's a transition, e.g referenced issues status goes from | |
|
164 | # open to resolved this is used in correlation with something like `closes #123` | |
|
153 | 165 | redmine_tracker.COMMENT_TEMPLATE_COMMIT_WITH_STATUS = redmine_tracker.Template(''' |
|
154 | 166 | Commit `${short_id}` by ${author} on `${branch}` branch changed this issue. \n |
|
155 | 167 | commit: ${url}\n |
|
156 | 168 | |
|
157 | 169 | ## MODIFICATION add custom COMMIT message to the comment |
|
158 | 170 | message: |
|
159 | 171 | ``` |
|
160 | 172 | ${commit['message']} |
|
161 | 173 | ``` |
|
162 | 174 | |
|
163 | 175 | ''') |
|
164 | 176 | |
|
165 | 177 | redmine_tracker.COMMENT_TEMPLATE_PULL_REQUEST = redmine_tracker.Template(''' |
|
166 | 178 | ${action} by ${author} (status: ${status}). \n' |
|
167 | 179 | ${url}\n |
|
168 | 180 | |
|
169 | 181 | ## MODIFICATION add custom COMMIT message to the comment |
|
170 | 182 | message: |
|
171 | 183 | ``` |
|
172 | 184 | ${commit['message']} |
|
173 | 185 | ``` |
|
174 | 186 | |
|
175 | 187 | ''') |
@@ -1,90 +1,91 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | # Copyright (C) 2016-2018 RhodeCode GmbH |
|
3 | 3 | # |
|
4 | 4 | # This program is free software: you can redistribute it and/or modify |
|
5 | 5 | # it under the terms of the GNU Affero General Public License, version 3 |
|
6 | 6 | # (only), as published by the Free Software Foundation. |
|
7 | 7 | # |
|
8 | 8 | # This program is distributed in the hope that it will be useful, |
|
9 | 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | 11 | # GNU General Public License for more details. |
|
12 | 12 | # |
|
13 | 13 | # You should have received a copy of the GNU Affero General Public License |
|
14 | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | 15 | # |
|
16 | 16 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | 17 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | 18 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | 19 | |
|
20 | 20 | """ |
|
21 | 21 | us in hooks:: |
|
22 | 22 | |
|
23 | 23 | from .helpers import extract_pre_commits |
|
24 | 24 | # returns list of dicts with key-val fetched from extra fields |
|
25 | 25 | commit_list = extract_pre_commits.run(**kwargs) |
|
26 | 26 | |
|
27 | 27 | """ |
|
28 | 28 | import re |
|
29 | 29 | import collections |
|
30 | 30 | import json |
|
31 | 31 | |
|
32 | 32 | |
|
33 | 33 | def get_hg_commits(repo, refs): |
|
34 | 34 | commits = [] |
|
35 | 35 | return commits |
|
36 | 36 | |
|
37 | 37 | |
|
38 | 38 | def get_git_commits(repo, refs): |
|
39 | 39 | commits = [] |
|
40 | 40 | |
|
41 | 41 | for data in refs: |
|
42 | 42 | # we should now extract commit data |
|
43 | 43 | old_rev = data['old_rev'] |
|
44 | 44 | new_rev = data['new_rev'] |
|
45 | 45 | |
|
46 | 46 | if '00000000' in old_rev: |
|
47 | 47 | # new branch, we don't need to extract nothing |
|
48 | 48 | return commits |
|
49 | 49 | |
|
50 | 50 | git_env = dict(data['git_env']) |
|
51 | # https://github.com/git/git/blob/master/Documentation/pretty-formats.txt | |
|
51 | 52 | cmd = [ |
|
52 | 53 | 'log', |
|
53 |
'--pretty=format:{"commit_id": "%H", "author": "%aN <%aE>", "date": "%ad", "message": "% |
|
|
54 | '--pretty=format:{"commit_id": "%H", "author": "%aN <%aE>", "date": "%ad", "message": "%s"}', | |
|
54 | 55 | '{}...{}'.format(old_rev, new_rev) |
|
55 | 56 | ] |
|
56 | 57 | |
|
57 | 58 | stdout, stderr = repo.run_git_command(cmd, extra_env=git_env) |
|
58 | 59 | for line in stdout.splitlines(): |
|
59 | 60 | try: |
|
60 | 61 | data = json.loads(line) |
|
61 | 62 | commits.append(data) |
|
62 | 63 | except Exception: |
|
63 | 64 | print('Failed to load data from GIT line') |
|
64 | 65 | |
|
65 | 66 | return commits |
|
66 | 67 | |
|
67 | 68 | |
|
68 | 69 | def run(*args, **kwargs): |
|
69 | 70 | from rhodecode.model.db import Repository |
|
70 | 71 | |
|
71 | 72 | vcs_type = kwargs['scm'] |
|
72 | 73 | # use temp name then the main one propagated |
|
73 | 74 | repo_name = kwargs.pop('REPOSITORY', None) or kwargs['repository'] |
|
74 | 75 | |
|
75 | 76 | repo = Repository.get_by_repo_name(repo_name) |
|
76 | 77 | vcs_repo = repo.scm_instance(cache=False) |
|
77 | 78 | |
|
78 | 79 | commits = [] |
|
79 | 80 | |
|
80 | 81 | if vcs_type == 'git': |
|
81 | 82 | for rev_data in kwargs['commit_ids']: |
|
82 | 83 | new_environ = dict((k, v) for k, v in rev_data['git_env']) |
|
83 | 84 | commits = get_git_commits(vcs_repo, kwargs['commit_ids']) |
|
84 | 85 | |
|
85 | 86 | if vcs_type == 'hg': |
|
86 | 87 | for rev_data in kwargs['commit_ids']: |
|
87 | 88 | new_environ = dict((k, v) for k, v in rev_data['hg_env']) |
|
88 | 89 | commits = get_hg_commits(vcs_repo, kwargs['commit_ids']) |
|
89 | 90 | |
|
90 | 91 | return commits |
General Comments 0
You need to be logged in to leave comments.
Login now