Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. def parent_commits(self, commit):
  2. logger.info('DEPLOY_DEBUG: iterating through parent commits...')
  3. p_commits = []
  4. for p in commit['object'].parents:
  5. # skip parent if it in database
  6. if TicketCommit.objects.filter(commit_hash=p.hexsha).exists():
  7. logger.info('DEPLOY_DEBUG: %s already in DB, skipped' %
  8. p.hexsha)
  9. continue
  10. p_commit = commit.copy()
  11. p_commit.update({
  12. 'object': p,
  13. 'who': '%s <%s>' % (p.author.name, p.author.email),
  14. 'comment': p.summary,
  15. 'revision': p.hexsha,
  16. })
  17. p_commit['diff'] = ''
  18. p_commits.append(p_commit)
  19. return p_commits
  20.  
  21. def process_commit(self, commit):
  22. """
  23. Process git commit
  24.  
  25. Commit: dict with fields:
  26. 'who': author
  27. 'comment': comment
  28. 'revision': commit hash
  29. 'branch': commit branch
  30. 'diff': merge diff
  31. 'commit_time': commit datetime
  32. 'deploy_result': deployment result
  33. """
  34. commits = []
  35. p_commits = self.parent_commits(commit)
  36. commits.append(commit)
  37. commits.append(p_commits)
  38.  
  39. for commit in commits:
  40. if commit.get('object'):
  41. commit['commit_time'] = datetime.datetime.fromtimestamp(
  42. commit['object'].committed_date
  43. )
  44.  
  45. logger.info('DEPLOY_DEBUG (%s): Incoming task' %
  46. commit.get('revision'))
  47.  
  48. commit_message = CommitProcessor.get_commit_message(
  49. commit.get('comment'))
  50. logger.debug('DEPLOY_DEBUG (%s): commit_message %s' %
  51. (commit.get('revision'), unicode(commit_message)))
  52.  
  53. # get ticket
  54. ticket = Ticket.get_instance(self.project,
  55. commit_message.get('ticket_id'))
  56. if not ticket:
  57. error_msg = 'Ticket %s does not exist in Kavyarnya.' % \
  58. commit_message.get('ticket_id', '<unknown>')
  59. self.parse_error(self.project, commit, self.pdc, error_msg)
  60. errors = {
  61. 'ticket': [error_msg],
  62. 'project': commit.get('project'),
  63. }
  64. logger.debug('DEPLOY_DEBUG (%s): %s' %
  65. (commit.get('revision'), unicode(errors)))
  66. return errors
  67.  
  68. logger.info('DEPLOY_DEBUG (%s): ticket is %s' %
  69. (commit.get('revision'), unicode(ticket)))
  70.  
  71. # push to master
  72. if commit.get('branch') == 'master':
  73. self.integration(ticket, commit)
  74.  
  75. # defect merged
  76. if 'Merge' in commit_message['message_label'] and \
  77. ticket.type == 'defect':
  78. self.merge(commit, ticket, commit_message)
  79.  
  80. self.get_trac_message(ticket, commit)
  81.  
  82. return None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement