'FROM ticket_change WHERE field="comment" AND ticket=%s' % tid): body = body.strip() if not body: continue comment_count += 1 body = convert_wikiformat(rev_mapping.convert(body)) if timestamp: timestamp = epoch_to_iso(timestamp) logging.debug(u' comment: {0}'.format(body[:70].replace(u'\r\n', u'\\n').replace(u'\n', u'\\n'))) # Don't worry about escaping--GitHub will handle these with Markdown formatter. comment_data.append(u'<tr><th style="text-align:left">Comment {2} by {0} at {1}</th></tr>'.format( author_mapping(author)['login'], timestamp, comment_count )) comment_data.append(u'<tr><td>\n{0}\n</td></tr>'.format(body)) comment_data.append(u'</table>') issue['body'] += u'\n' + u'\n'.join(comment_data) # Save the issue. # NOTE: we cannot set the issue number when creating. try: result = github.issues(data=issue) logging.debug('New issue no.: {0} => {1}'.format(tid, result['number'])) if status == 'closed': # Unfortunately, we should use another query to close it. github.issues(result['number'], data={'state': 'closed'}) except ValueError as e: logging.error(e) # TEMPORARY continue trac.close()
issue['created_at'] = epoch_to_iso(created_at) if updated_at: issue['updated_at'] = epoch_to_iso(updated_at) issue['labels'] = [] if keywords: issue['labels'].extend([{'name' : keyword} for keyword in keywords]) if severity: issue['labels'].append({'name' : severity}) if priority: issue['labels'].append({'name' : priority}) if resolution: issue['labels'].append({'name' : resolution}) if type: issue['labels'].append({'name' : type}) # save issue github.issues(tid, data=issue) # Add comments comment_data = [] comments = trac.sql('SELECT author, newvalue, time AS body FROM ticket_change WHERE field="comment" AND ticket=%s' % tid) for author, body, timestamp in comments: body = body.strip() if body: # replace svn commit with git one if options.checkout: # search for [12345], r12345 changeset formats body = re.sub(r'[r\[](\d+)[\W]', svn_to_git_mapper, body) # prefix comment with author as git doesn't keep them separate if author: body = "%s: %s" % (author, body) if timestamp: timestamp = epoch_to_iso(timestamp)