Esempio n. 1
0
    def collab(self, commit, author=None):
        '''
        Creates a code review in code collaborator from the git logs if there is
        a 'reviewers' annotation in the commit message
        '''
        if 'reviewers' in commit['annotations']:
            reviewers = commit['annotations']['reviewers']
            cc = CodeCollabClient()
            review_id = cc.create_collab(commit['title'], commit['overview'])
            if author is None:
                author = cc.get_current_user()
            cc.add_reviewers(review_id, author, reviewers)
            cc.add_diffs(review_id, commit['unified_diff'])
            cc.done(review_id)

            work_name = self.get_work_name(commit)
            if work_name is not None:
                gus = self.__gus_session__(commit)
                work = gus.find_work(work_name)
                gus.add_collab_link(work, cc.get_review_link(review_id))

            print 'Created code review %s for author %s' % (review_id, author)
        elif 'update_review' in commit['annotations']:
            review_id = commit['annotations']['update_review']
            cc = CodeCollabClient()
            cc.add_diffs(review_id,
                         commit['unified_diff'],
                         comment='Updated Files from Commit')
            cc.add_comment(review_id, commit['title'])
            print 'Updated review %s with changes from commit' % review_id
        else:
            print 'No reviewers specified for commit, can\'t create review.  Use @reviewers or @update_review'
Esempio n. 2
0
 def collab(self, commit, author=None):
     '''
     Creates a code review in code collaborator from the git logs if there is
     a 'reviewers' annotation in the commit message
     '''
     if 'reviewers' in commit['annotations']:
         reviewers = commit['annotations']['reviewers']
         cc = CodeCollabClient()
         review_id = cc.create_collab(commit['title'], commit['overview'])
         if author is None:
             author = cc.get_current_user()
         cc.add_reviewers(review_id, author, reviewers)
         cc.add_diffs(review_id, commit['unified_diff'])
         cc.done(review_id)
         
         work_name = self.get_work_name(commit)
         if work_name is not None:
             gus = self.__gus_session__(commit)
             work = gus.find_work(work_name)
             gus.add_collab_link(work, cc.get_review_link(review_id))
             
         print 'Created code review %s for author %s' % (review_id, author)
     elif 'update_review' in commit['annotations']:
         review_id = commit['annotations']['update_review']
         cc = CodeCollabClient()
         cc.add_diffs(review_id, commit['unified_diff'], comment='Updated Files from Commit')
         cc.add_comment(review_id, commit['title'])
         print 'Updated review %s with changes from commit' % review_id
     else:
         print 'No reviewers specified for commit, can\'t create review.  Use @reviewers or @update_review'