| 1 impot hgapi |
1 import hgapi |
| |
2 import time |
| |
3 import re |
| |
4 import bt as Bt |
| |
5 import irc as Irc |
| |
6 from datetime import datetime |
| 2 from configfile import Config |
7 from configfile import Config |
| 3 g_needCommitsTxtRebuild = True |
8 g_needCommitsTxtRebuild = True |
| 4 |
9 |
| 5 def make_commits_txt(): |
10 def make_commits_txt(): |
| 6 global g_needCommitsTxtRebuild |
11 global g_needCommitsTxtRebuild |
| 7 |
12 |
| 8 if g_needCommitsTxtRebuild == False: |
13 if g_needCommitsTxtRebuild == False: |
| 9 return |
14 return |
| 10 |
15 |
| 11 print 'Building commits.txt...' |
16 print 'Building commits.txt...' |
| 12 # Update zandronum-everything |
17 # Update zandronum-everything |
| 13 repo = hgapi.Repo ('zandronum-everything') |
18 repo = hgapi.Repo ('zandronum-everything') |
| 14 repo.hg_command ('pull', '../zandronum-sandbox') |
19 repo.hg_command ('pull', '../zandronum-sandbox') |
| 15 repo.hg_command ('pull', '../zandronum-sandbox-stable') |
20 repo.hg_command ('pull', '../zandronum-sandbox-stable') |
| 16 |
|
| 17 data = repo.hg_command ('log', '--template', '{node} {date|hgdate}\n') |
21 data = repo.hg_command ('log', '--template', '{node} {date|hgdate}\n') |
| 18 |
|
| 19 f = open ('commits.txt', 'w') |
22 f = open ('commits.txt', 'w') |
| 20 |
23 |
| 21 for line in data.split ('\n'): |
24 for line in data.split ('\n'): |
| 22 if line == '': |
25 if line == '': |
| 23 continue |
26 continue |
| 24 |
27 |
| 25 words = line.split (' ') |
28 words = line.split (' ') |
| 26 timestamp = int (words[1]) |
29 timestamp = int (words[1]) |
| 27 f.write ('%s %s\n' % (words[0], datetime.utcfromtimestamp (timestamp).strftime ('%y%m%d-%H%M'))) |
30 f.write ('%s %s\n' % (words[0], datetime.utcfromtimestamp (timestamp).strftime ('%y%m%d-%H%M'))) |
| |
31 |
| 28 f.close() |
32 f.close() |
| 29 g_needCommitsTxtRebuild = False |
33 g_needCommitsTxtRebuild = False |
| 30 #enddef |
|
| 31 |
34 |
| 32 ' Check if a repository exists ' |
35 ' Check if a repository exists ' |
| 33 def check_repo_exists (repo_name, repo_owner): |
36 def check_repo_exists (repo_name, repo_owner): |
| 34 print 'Checking that %s exists...' % repo_name |
37 print 'Checking that %s exists...' % repo_name |
| 35 repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name) |
38 repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name) |
| 36 zanrepo = hgapi.Repo (repo_name) |
39 zanrepo = hgapi.Repo (repo_name) |
| 37 |
40 |
| 38 try: |
41 try: |
| 39 zanrepo.hg_command ('id', '.') |
42 zanrepo.hg_command ('id', '.') |
| 40 except hgapi.hgapi.HgException: |
43 except hgapi.hgapi.HgException: |
| 41 # If the repo does not exist, clone it. zandronum-everything can be spawned off other repos though |
44 # If the repo does not exist, clone it. zandronum-everything can be spawned off other repos though |
| 42 if repo_name == 'zandronum-everything': |
45 if repo_name == 'zandronum-everything': |
| 43 if not os.path.exists (repo_name): |
46 if not os.path.exists (repo_name): |
| 44 os.makedirs (repo_name) |
47 os.makedirs (repo_name) |
| 45 |
48 |
| 46 global g_needCommitsTxtRebuild |
49 global g_needCommitsTxtRebuild |
| 47 g_needCommitsTxtRebuild = True |
50 g_needCommitsTxtRebuild = True |
| 48 print 'Init %s' % repo_name |
51 print 'Init %s' % repo_name |
| 49 zanrepo.hg_command ('init') |
52 zanrepo.hg_command ('init') |
| 50 print 'Cloning zandronum-sandbox into %s' % repo_name |
53 print 'Cloning zandronum-sandbox into %s' % repo_name |
| 52 print 'Cloning zandronum-sandbox-stable into %s' % repo_name |
55 print 'Cloning zandronum-sandbox-stable into %s' % repo_name |
| 53 zanrepo.hg_command ('pull', '../zandronum-sandbox-stable') |
56 zanrepo.hg_command ('pull', '../zandronum-sandbox-stable') |
| 54 print 'Done' |
57 print 'Done' |
| 55 make_commits_txt() |
58 make_commits_txt() |
| 56 return |
59 return |
| 57 #fi |
60 |
| 58 |
|
| 59 try: |
61 try: |
| 60 print 'Cloning %s...' % repo_name |
62 print 'Cloning %s...' % repo_name |
| 61 zanrepo.hg_clone (repo_url, repo_name) |
63 zanrepo.hg_clone (repo_url, repo_name) |
| 62 print 'Cloning done.' |
64 print 'Cloning done.' |
| 63 except Exception as e: |
65 except Exception as e: |
| 64 print 'Unable to clone %s from %s: %s' % (repo_name, repo_url, str (`e`)) |
66 print 'Unable to clone %s from %s: %s' % (repo_name, repo_url, str (`e`)) |
| 65 quit(1) |
67 quit (1) |
| 66 #tried |
68 |
| 67 #enddef |
69 def init(): |
| 68 |
70 check_repo_exists ('zandronum', 'Torr_Samaho') |
| 69 check_repo_exists ('zandronum', 'Torr_Samaho') |
71 check_repo_exists ('zandronum-stable', 'Torr_Samaho') |
| 70 check_repo_exists ('zandronum-stable', 'Torr_Samaho') |
72 check_repo_exists ('zandronum-sandbox', 'crimsondusk') |
| 71 check_repo_exists ('zandronum-sandbox', 'crimsondusk') |
73 check_repo_exists ('zandronum-sandbox-stable', 'crimsondusk') |
| 72 check_repo_exists ('zandronum-sandbox-stable', 'crimsondusk') |
74 check_repo_exists ('zandronum-everything', '') |
| 73 check_repo_exists ('zandronum-everything', '') |
75 global repocheck_timeout |
| 74 |
76 repocheck_timeout = (time.time()) + 15 |
| 75 repocheck_timeout = (time.time()) + 15 |
|
| 76 |
77 |
| 77 def get_commit_data (zanrepo, rev, template): |
78 def get_commit_data (zanrepo, rev, template): |
| 78 return zanrepo.hg_command ('log', '-l', '1', '-r', rev, '--template', template) |
79 return zanrepo.hg_command ('log', '-l', '1', '-r', rev, '--template', template) |
| 79 #enddef |
|
| 80 |
80 |
| 81 def decipher_hgapi_error (e): |
81 def decipher_hgapi_error (e): |
| 82 # Blah, hgapi, why must your error messages be so mangled? |
82 # Blah, hgapi, why must your error messages be so mangled? |
| 83 try: |
83 try: |
| 84 rawmsg = e.message.replace('\n', '').replace('" +','').replace('\t','') |
84 rawmsg = e.message.replace('\n', '').replace('" +','').replace('\t','') |
| 85 errmsg = re.compile (r'.*: tErr: (.*)Out:.*').match (rawmsg).group (1) |
85 errmsg = re.compile (r'.*: tErr: (.*)Out:.*').match (rawmsg).group (1) |
| 86 return [True, errmsg] |
86 return [True, errmsg] |
| 87 except: |
87 except: |
| 88 return [False, ''] |
88 return [False, ''] |
| 89 #endtry |
89 |
| 90 #enddef |
90 def bbcodify (commit_diffstat): |
| 91 |
91 result = '' |
| 92 def bbcodify(commit_diffstat): |
92 |
| 93 result='' |
|
| 94 for line in commit_diffstat.split('\n'): |
93 for line in commit_diffstat.split('\n'): |
| 95 # Add green color-tags for the ++++++++++ stream |
|
| 96 rex = re.compile (r'^(.*)\|(.*) (\+*)(-*)(.*)$') |
94 rex = re.compile (r'^(.*)\|(.*) (\+*)(-*)(.*)$') |
| 97 match = rex.match (line) |
95 match = rex.match (line) |
| 98 if match: |
96 if match: |
| 99 line = '%s|%s [color=#5F7]%s[/color][color=#F53]%s[/color]%s\n' \ |
97 line = '%s|%s [color=#5F7]%s[/color][color=#F53]%s[/color]%s\n' \ |
| 100 % (match.group (1), match.group (2), match.group (3), match.group (4), match.group (5)) |
98 % (match.group (1), match.group (2), match.group (3), match.group (4), match.group (5)) |
| 101 |
99 |
| 102 # Tracker doesn't seem to like empty color tags |
100 # Tracker doesn't seem to like empty color tags |
| 103 line = line.replace ('[color=#5F7][/color]', '').replace ('[color=#F53][/color]', '') |
101 line = line.replace ('[color=#5F7][/color]', '').replace ('[color=#F53][/color]', '') |
| 104 #else: |
102 |
| 105 #rex = re.compile (r'^(.*) ([0-9]+) insertions\(\+\), ([0-9]+) deletions\(\-\)$') |
|
| 106 #match = rex.match (line) |
|
| 107 #if match: |
|
| 108 #line = '%s [b][color=green]%s[/color][/b] insertions, [b][color=red]%s[/color][/b] deletions\n' \ |
|
| 109 #% (match.group (1), match.group (2), match.group (3)) |
|
| 110 |
|
| 111 result += line |
103 result += line |
| 112 #done |
104 |
| 113 |
|
| 114 return result |
105 return result |
| 115 #enddef |
|
| 116 |
106 |
| 117 def find_developer_by_email (commit_email): |
107 def find_developer_by_email (commit_email): |
| 118 for developer, emails in Config.get_value ('developer_emails', default={}).iteritems(): |
108 for developer, emails in Config.get_value ('developer_emails', default={}).iteritems(): |
| 119 for email in emails: |
109 if commit_email in emails: |
| 120 if commit_email == email: |
110 return developer |
| 121 return developer |
111 |
| 122 #fi |
|
| 123 #done |
|
| 124 #done |
|
| 125 |
|
| 126 return '' |
112 return '' |
| 127 #enddef |
113 |
| 128 |
|
| 129 ' Retrieves and processes commits for zandronum repositories ' |
|
| 130 ' Ensure both repositories are OK before using this! ' |
|
| 131 def poll(): |
114 def poll(): |
| |
115 global repocheck_timeout |
| |
116 if time.time() < repocheck_timeout: |
| |
117 return |
| |
118 |
| 132 for n in ['zandronum-stable', 'zandronum', 'zandronum-sandbox', 'zandronum-sandbox-stable']: |
119 for n in ['zandronum-stable', 'zandronum', 'zandronum-sandbox', 'zandronum-sandbox-stable']: |
| 133 process_one_repo (n) |
120 poll_one_repo (n) |
| 134 |
121 |
| 135 def process_one_repo (repo_name): |
122 hgns = Config.get_node ('hg') |
| |
123 repocheck_timeout = time.time() + hgns.get_value ('checkinterval', default=15) * 60 |
| |
124 |
| |
125 def poll_one_repo (repo_name): |
| 136 global repocheck_timeout |
126 global repocheck_timeout |
| 137 global g_clients |
|
| 138 |
|
| 139 hgns = Config.get_node ('hg') |
127 hgns = Config.get_node ('hg') |
| 140 |
128 |
| 141 if not hgns.get_value ('track', default=True): |
129 if not hgns.get_value ('track', default=True): |
| 142 return |
130 return |
| 143 |
131 |
| 144 usestable = repo_name == 'zandronum-stable' |
132 usestable = repo_name == 'zandronum-stable' |
| 145 usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable' |
133 usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable' |
| 146 repo_owner = 'Torr_Samaho' if not usesandbox else 'crimsondusk' |
134 repo_owner = 'Torr_Samaho' if not usesandbox else 'crimsondusk' |
| 147 repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name) |
135 repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name) |
| 148 num_commits = 0 |
136 num_commits = 0 |
| 149 btuser, btpassword = bt_credentials() |
|
| 150 |
|
| 151 if time.time() < repocheck_timeout: |
|
| 152 return |
|
| 153 |
|
| 154 repocheck_timeout = time.time() + hgns.get_value ('checkinterval', default=15) * 60 |
|
| 155 zanrepo = hgapi.Repo (repo_name) |
137 zanrepo = hgapi.Repo (repo_name) |
| 156 commit_data = [] |
138 commit_data = [] |
| 157 delimeter = '@@@@@@@@@@' |
139 delimeter = '@@@@@@@@@@' |
| 158 |
140 print 'Checking %s for updates' % repo_name |
| |
141 |
| 159 try: |
142 try: |
| 160 data = zanrepo.hg_command ('incoming', '--quiet', '--template', |
143 data = zanrepo.hg_command ('incoming', '--quiet', '--template', |
| 161 '{node|short} {desc}' + delimeter) |
144 '{node|short} {desc}' + delimeter) |
| 162 except hgapi.hgapi.HgException as e: |
145 except hgapi.hgapi.HgException as e: |
| 163 deciphered = decipher_hgapi_error (e) |
146 deciphered = decipher_hgapi_error (e) |
| 164 |
147 |
| 165 if deciphered[0] and len(deciphered[1]) > 0: |
148 if deciphered[0] and len(deciphered[1]) > 0: |
| 166 chanlog ("error while using hg import on %s: %s" % (repo_name, deciphered[1])) |
149 Irc.broadcast ("error while using hg import on %s: %s" % (repo_name, deciphered[1])) |
| 167 #fi |
150 |
| 168 |
|
| 169 return |
151 return |
| 170 except Exception as e: |
152 except Exception as e: |
| 171 chanlog ("%s" % `e`) |
153 Irc.broadcast ("%s" % `e`) |
| 172 return |
154 return |
| 173 #tried |
155 |
| 174 |
|
| 175 for line in data.split (delimeter): |
156 for line in data.split (delimeter): |
| 176 if line == '': |
157 if line == '': |
| 177 continue |
158 continue |
| 178 #fi |
159 |
| 179 |
|
| 180 rex = re.compile (r'([^ ]+) (.+)') |
160 rex = re.compile (r'([^ ]+) (.+)') |
| 181 match = rex.match (line) |
161 match = rex.match (line) |
| 182 failed = False |
162 failed = False |
| 183 |
163 |
| 184 if not match: |
164 if not match: |
| 185 chanlog ('malformed hg data: %s' % line) |
165 Irc.broadcast ('malformed hg data: %s' % line) |
| 186 continue |
166 continue |
| 187 #fi |
167 |
| 188 |
|
| 189 commit_node = match.group (1) |
168 commit_node = match.group (1) |
| 190 commit_message = match.group (2) |
169 commit_message = match.group (2) |
| 191 commit_data.append ([commit_node, commit_message]) |
170 commit_data.append ([commit_node, commit_message]) |
| 192 #done |
171 |
| 193 |
172 print '%d new commits on %s' % (len (commit_data), repo_name) |
| |
173 |
| 194 if len (commit_data) > 0: |
174 if len (commit_data) > 0: |
| 195 pull_args = []; |
175 pull_args = []; |
| 196 |
176 |
| 197 for commit in commit_data: |
177 for commit in commit_data: |
| 198 pull_args.append ('-r'); |
178 pull_args.append ('-r'); |
| 199 pull_args.append (commit[0]); |
179 pull_args.append (commit[0]); |
| 200 #done |
180 |
| 201 |
181 print 'Pulling new commits...' |
| 202 try: |
182 try: |
| 203 zanrepo.hg_command ('pull', *pull_args) |
183 zanrepo.hg_command ('pull', *pull_args) |
| 204 |
184 |
| 205 # Also pull these commits to the zandronum main repository |
185 # Also pull these commits to the zandronum main repository |
| 206 if usestable: |
186 if usestable: |
| 207 devrepo = hgapi.Repo ('zandronum') |
187 devrepo = hgapi.Repo ('zandronum') |
| 208 devrepo.hg_command ('pull', '../zandronum-stable', *pull_args) |
188 devrepo.hg_command ('pull', '../zandronum-stable', *pull_args) |
| 209 #fi |
189 |
| 210 |
|
| 211 # Pull everything into sandboxes too |
190 # Pull everything into sandboxes too |
| 212 if not usesandbox: |
191 if not usesandbox: |
| 213 devrepo = hgapi.Repo ('zandronum-sandbox') |
192 devrepo = hgapi.Repo ('zandronum-sandbox') |
| 214 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args) |
193 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args) |
| 215 |
194 |
| 216 devrepo = hgapi.Repo ('zandronum-sandbox-stable') |
195 devrepo = hgapi.Repo ('zandronum-sandbox-stable') |
| 217 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args) |
196 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args) |
| 218 #fi |
197 |
| 219 |
|
| 220 devrepo = hgapi.Repo ('zandronum-everything') |
198 devrepo = hgapi.Repo ('zandronum-everything') |
| 221 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args) |
199 devrepo.hg_command ('pull', '../%s' % repo_name, *pull_args) |
| 222 |
200 |
| 223 global g_needCommitsTxtRebuild |
201 global g_needCommitsTxtRebuild |
| 224 g_needCommitsTxtRebuild = True |
202 g_needCommitsTxtRebuild = True |
| 225 except Exception as e: |
203 except Exception as e: |
| 226 chanlog ('Warning: unable to pull: %s' % `e`) |
204 Irc.broadcast ('Warning: unable to pull: %s' % `e`) |
| 227 return |
205 return |
| 228 #tried |
206 |
| 229 #fi |
|
| 230 |
|
| 231 for commit in commit_data: |
207 for commit in commit_data: |
| 232 commit_node = commit[0] |
208 commit_node = commit[0] |
| 233 commit_message = commit[1] |
209 commit_message = commit[1] |
| 234 |
210 print 'Processing new commit %s...' % commit_node |
| |
211 |
| 235 try: |
212 try: |
| 236 if usesandbox: |
213 if usesandbox: |
| 237 commit_author = get_commit_data (zanrepo, commit_node, '{author}') |
214 commit_author = get_commit_data (zanrepo, commit_node, '{author}') |
| 238 commit_url = '%s/commits/%s' % (repo_url, commit_node) |
215 commit_url = '%s/commits/%s' % (repo_url, commit_node) |
| 239 commit_email = '' |
216 commit_email = '' |
| 240 |
217 |
| 241 # Remove the email address from the author if possible |
218 # Remove the email address from the author if possible |
| 242 rex = re.compile (r'^(.+) <([^>]+)>$.*') |
219 rex = re.compile (r'^(.+) <([^>]+)>$.*') |
| 243 match = rex.match (commit_author) |
220 match = rex.match (commit_author) |
| 244 if match: |
221 if match: |
| 245 commit_author = match.group (1) |
222 commit_author = match.group (1) |
| 246 commit_email = match.group (2) |
223 commit_email = match.group (2) |
| 247 #fi |
224 |
| 248 |
|
| 249 commit_trackeruser = find_developer_by_email (commit_email) |
225 commit_trackeruser = find_developer_by_email (commit_email) |
| 250 committer = commit_trackeruser if commit_trackeruser != '' else commit_author |
226 committer = commit_trackeruser if commit_trackeruser != '' else commit_author |
| 251 |
227 |
| 252 for irc_client in g_clients: |
228 for irc_client in Irc.all_clients: |
| 253 for channel in irc_client.cfg['channels']: |
229 for channel in irc_client.channels: |
| 254 if 'btprivate' in channel and channel['btprivate'] == True: |
230 if channel.get_value ('btprivate', False): |
| 255 irc_client.privmsg (channel['name'], |
231 irc_client.privmsg (channel.get_value ('name'), |
| 256 "%s: new commit %s by %s: %s" |
232 "%s: new commit %s by %s: %s" |
| 257 % (repo_name, commit_node, committer, commit_url)) |
233 % (repo_name, commit_node, committer, commit_url)) |
| 258 |
234 |
| 259 for line in commit_message.split ('\n'): |
235 for line in commit_message.split ('\n'): |
| 260 irc_client.privmsg (channel['name'], line) |
236 irc_client.privmsg (channel.get_value ('name'), line) |
| 261 #fi |
237 |
| 262 #done |
|
| 263 #done |
|
| 264 |
|
| 265 num_commits += 1 |
238 num_commits += 1 |
| 266 continue |
239 continue |
| 267 #fi |
240 |
| 268 |
|
| 269 rex = re.compile (r'^.*(fixes|resolves|addresses|should fix) ([0-9]+).*$') |
241 rex = re.compile (r'^.*(fixes|resolves|addresses|should fix) ([0-9]+).*$') |
| 270 match = rex.match (commit_message) |
242 match = rex.match (commit_message) |
| 271 |
243 |
| 272 if not match: |
244 if not match: |
| 273 continue # no "fixes" message in the commit |
245 continue # no "fixes" message in the commit |
| 274 #fi |
246 |
| 275 |
|
| 276 ticket_id = int (match.group (2)) |
247 ticket_id = int (match.group (2)) |
| 277 |
248 |
| 278 # Acquire additional data |
249 # Acquire additional data |
| 279 moredata = get_commit_data (zanrepo, commit_node, |
250 moredata = get_commit_data (zanrepo, commit_node, |
| 280 '{author|nonempty}\n{date(date, \'%A %d %B %Y %T\')}').split('\n') |
251 '{author|nonempty}\n{date(date, \'%A %d %B %Y %T\')}').split('\n') |
| 281 |
252 |
| 282 if len (moredata) != 2: |
253 if len (moredata) != 2: |
| 283 chanlog ('error while processing %s: malformed hg data' % commit_node) |
254 Irc.broadcast ('error while processing %s: malformed hg data' % commit_node) |
| 284 continue |
255 continue |
| 285 #fi |
256 |
| 286 |
|
| 287 commit_author = moredata[0] |
257 commit_author = moredata[0] |
| 288 commit_date = moredata[1] |
258 commit_date = moredata[1] |
| 289 commit_email = "" |
259 commit_email = "" |
| 290 |
260 |
| 291 try: |
261 try: |
| 292 ticket_data = suds_client.service.mc_issue_get (btuser, btpassword, ticket_id) |
262 ticket_data = Bt.get_issue (ticket_id) |
| 293 except Exception as e: |
263 except Exception as e: |
| 294 chanlog ('error while processing %s: %s' % (commit_node, `e`)) |
264 Irc.broadcast ('error while processing %s: %s' % (commit_node, `e`)) |
| 295 continue |
265 continue |
| 296 #tried |
266 |
| 297 |
|
| 298 # Remove the email address from the author if possible |
267 # Remove the email address from the author if possible |
| 299 rex = re.compile (r'^(.+) <([^>]+)>$.*') |
268 rex = re.compile (r'^(.+) <([^>]+)>$.*') |
| 300 match = rex.match (commit_author) |
269 match = rex.match (commit_author) |
| 301 if match: |
270 if match: |
| 302 commit_author = match.group (1) |
271 commit_author = match.group (1) |
| 303 commit_email = match.group (2) |
272 commit_email = match.group (2) |
| 304 #fi |
273 |
| 305 |
|
| 306 commit_diffstat = zanrepo.hg_command ('diff', '--change', commit_node, '--stat') |
274 commit_diffstat = zanrepo.hg_command ('diff', '--change', commit_node, '--stat') |
| 307 |
275 |
| 308 if len(commit_diffstat) > 0: |
276 if len(commit_diffstat) > 0: |
| 309 # commit_diffstat = 'Changes in files:\n[code]\n' + commit_diffstat + '\n[/code]' |
277 # commit_diffstat = 'Changes in files:\n[code]\n' + commit_diffstat + '\n[/code]' |
| 310 commit_diffstat = 'Changes in files:\n' + bbcodify(commit_diffstat) |
278 commit_diffstat = 'Changes in files:\n' + bbcodify(commit_diffstat) |
| 311 else: |
279 else: |
| 312 commit_diffstat = 'No changes in files.' |
280 commit_diffstat = 'No changes in files.' |
| 313 |
281 |
| 314 # Compare the email addresses against known developer usernames |
282 # Compare the email addresses against known developer usernames |
| 315 commit_trackeruser = find_developer_by_email (commit_email) |
283 commit_trackeruser = find_developer_by_email (commit_email) |
| 316 |
284 |
| 317 if commit_trackeruser != '': |
285 if commit_trackeruser != '': |
| 318 commit_author += ' [%s]' % commit_trackeruser |
286 commit_author += ' [%s]' % commit_trackeruser |
| 319 #fi |
287 |
| 320 |
|
| 321 message = 'Issue addressed by commit %s: [b][url=%s/commits/%s]%s[/url][/b]' \ |
288 message = 'Issue addressed by commit %s: [b][url=%s/commits/%s]%s[/url][/b]' \ |
| 322 % (commit_node, repo_url, commit_node, commit_message) |
289 % (commit_node, repo_url, commit_node, commit_message) |
| 323 message += "\nCommitted by %s on %s\n\n%s" \ |
290 message += "\nCommitted by %s on %s\n\n%s" \ |
| 324 % (commit_author, commit_date, commit_diffstat) |
291 % (commit_author, commit_date, commit_diffstat) |
| 325 |
292 |
| 326 need_update = False |
293 need_update = False |
| 327 |
294 |
| 328 # If not already set, set handler |
295 # If not already set, set handler |
| 329 if not 'handler' in ticket_data: |
296 if not 'handler' in ticket_data: |
| 330 ticket_data['handler'] = {'name': commit_trackeruser} |
297 ticket_data['handler'] = {'name': commit_trackeruser} |
| 331 need_update = True |
298 need_update = True |
| 332 #fi |
299 |
| 333 |
|
| 334 # Find out the status level of the ticket |
300 # Find out the status level of the ticket |
| 335 needs_testing_level = 70 |
301 needs_testing_level = 70 |
| 336 |
302 |
| 337 if ticket_data['status']['id'] < needs_testing_level: |
303 if ticket_data['status']['id'] < needs_testing_level: |
| 338 ticket_data.status['id'] = needs_testing_level |
304 ticket_data.status['id'] = needs_testing_level |
| 339 need_update = True |
305 need_update = True |
| 340 #fi |
306 |
| 341 |
|
| 342 # Set target version if not set |
307 # Set target version if not set |
| 343 if not 'target_version' in ticket_data: |
308 if not 'target_version' in ticket_data: |
| 344 ticket_data['target_version'] = '1.4' if repo_name == 'zandronum-stable' else '2.0' |
309 ticket_data['target_version'] = '1.4' if repo_name == 'zandronum-stable' else '2.0' |
| 345 need_update = True |
310 need_update = True |
| 346 elif (ticket_data['target_version'] == '2.0' or ticket_data['target_version'] == '2.0-beta') \ |
311 elif (ticket_data['target_version'] == '2.0' or ticket_data['target_version'] == '2.0-beta') \ |