Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def parent_commits(self, commit):
- logger.info('DEPLOY_DEBUG: iterating through parent commits...')
- p_commits = []
- for p in commit['object'].parents:
- # skip parent if it in database
- if TicketCommit.objects.filter(commit_hash=p.hexsha).exists():
- logger.info('DEPLOY_DEBUG: %s already in DB, skipped' %
- p.hexsha)
- continue
- p_commit = commit.copy()
- p_commit.update({
- 'object': p,
- 'who': '%s <%s>' % (p.author.name, p.author.email),
- 'comment': p.summary,
- 'revision': p.hexsha,
- })
- p_commit['diff'] = ''
- p_commits.append(p_commit)
- return p_commits
- def process_commit(self, commit):
- """
- Process git commit
- Commit: dict with fields:
- 'who': author
- 'comment': comment
- 'revision': commit hash
- 'branch': commit branch
- 'diff': merge diff
- 'commit_time': commit datetime
- 'deploy_result': deployment result
- """
- commits = []
- p_commits = self.parent_commits(commit)
- commits.append(commit)
- commits.append(p_commits)
- for commit in commits:
- if commit.get('object'):
- commit['commit_time'] = datetime.datetime.fromtimestamp(
- commit['object'].committed_date
- )
- logger.info('DEPLOY_DEBUG (%s): Incoming task' %
- commit.get('revision'))
- commit_message = CommitProcessor.get_commit_message(
- commit.get('comment'))
- logger.debug('DEPLOY_DEBUG (%s): commit_message %s' %
- (commit.get('revision'), unicode(commit_message)))
- # get ticket
- ticket = Ticket.get_instance(self.project,
- commit_message.get('ticket_id'))
- if not ticket:
- error_msg = 'Ticket %s does not exist in Kavyarnya.' % \
- commit_message.get('ticket_id', '<unknown>')
- self.parse_error(self.project, commit, self.pdc, error_msg)
- errors = {
- 'ticket': [error_msg],
- 'project': commit.get('project'),
- }
- logger.debug('DEPLOY_DEBUG (%s): %s' %
- (commit.get('revision'), unicode(errors)))
- return errors
- logger.info('DEPLOY_DEBUG (%s): ticket is %s' %
- (commit.get('revision'), unicode(ticket)))
- # push to master
- if commit.get('branch') == 'master':
- self.integration(ticket, commit)
- # defect merged
- if 'Merge' in commit_message['message_label'] and \
- ticket.type == 'defect':
- self.merge(commit, ticket, commit_message)
- self.get_trac_message(ticket, commit)
- return None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement