예제 #1
0
def _CanCommitRevert(parameters, analysis_id, codereview_info):
    """Checks if an auto-created revert of a culprit can be committed.

  This function will call several different functions to check the culprit
  and/or revert from many different aspects and make the final decision.

  The criteria included so far are:
   + Revert is created by Findit;
   + Can the revert be committed in current analysis;
   + Was the change committed within time;
   + Was the change to be reverted authored by an auto-roller;
   + Are there other changes by the culprit's author depending on the culprit.
  """
    if not parameters.revert_status == constants.CREATED_BY_FINDIT:
        return False

    culprit = entity_util.GetEntityFromUrlsafeKey(parameters.cl_key)
    assert culprit

    action_settings = waterfall_config.GetActionSettings()
    culprit_commit_limit_hours = action_settings.get(
        'culprit_commit_limit_hours',
        constants.DEFAULT_CULPRIT_COMMIT_LIMIT_HOURS)

    return (_CanCommitRevertInAnalysis(parameters.cl_key, analysis_id)
            and git.ChangeCommittedWithinTime(culprit.revision,
                                              hours=culprit_commit_limit_hours)
            and not git.IsAuthoredByNoAutoRevertAccount(culprit.revision)
            and not gerrit.ExistCQedDependingChanges(codereview_info))
예제 #2
0
 def testExistCQedDependingChangesNoDependingCL(self, mock_query, _):
     cl_info = ClInfo(self.review_server_host, self.review_change_id)
     cl_info.patchsets['12345-rev1'] = PatchSet('1', '12345-rev1', [])
     cl_info.patchsets['12345-rev1'] = PatchSet('2', '12345-rev2', [])
     mock_query.return_value = [cl_info]
     self.assertFalse(gerrit.ExistCQedDependingChanges(
         self.codereview_info))
예제 #3
0
    def testExistCQedDependingChanges(self, mock_query, _):
        cl_info = ClInfo(self.review_server_host, self.review_change_id)
        cl_info.patchsets['12345-rev1'] = PatchSet('1', '12345-rev1', [])
        cl_info.patchsets['12345-rev1'] = PatchSet('2', '12345-rev2', [])

        cl_info_1 = ClInfo(self.review_server_host, '12346')
        cl_info_1.patchsets['12346-rev1'] = PatchSet('1', '12346-rev1',
                                                     ['unrelated'])
        cl_info_1.patchsets['12346-rev2'] = PatchSet('2', '12346-rev2',
                                                     ['unrelated'])

        cl_info_2 = ClInfo(self.review_server_host, '12347')
        cl_info_2.patchsets['12347-rev1'] = PatchSet('1', '12347-rev1',
                                                     ['12345-rev1'])
        cl_info_2.patchsets['12347-rev2'] = PatchSet('2', '12347-rev2',
                                                     ['unrelated'])

        cl_info_3 = ClInfo(self.review_server_host, '12348')
        cl_info_3.patchsets['12348-rev1'] = PatchSet('1', '12348-rev1',
                                                     ['unrelated'])
        cl_info_3.patchsets['12348-rev2'] = PatchSet('2', '12348-rev2',
                                                     ['unrelated'])
        mock_query.return_value = [cl_info, cl_info_1, cl_info_2, cl_info_3]
        self.assertTrue(gerrit.ExistCQedDependingChanges(self.codereview_info))
예제 #4
0
 def testExistCQedDependingChangesIncompleteInfo(self):
     self.assertFalse(
         gerrit.ExistCQedDependingChanges({'review_change_id': '123456'}))
예제 #5
0
 def testExistCQedChangesDependingOnCulpritLoseInfo(self):
     self.assertFalse(gerrit.ExistCQedDependingChanges({}))
예제 #6
0
 def testExistCQedDependingChangesNoCLs(self, mock_query, _):
     mock_query.return_value = []
     self.assertFalse(gerrit.ExistCQedDependingChanges(
         self.codereview_info))