OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 """The revert checkbox must be checked by a project committer.""" |
| 7 |
| 8 |
| 9 from verification import base |
| 10 |
| 11 import re |
| 12 |
| 13 |
| 14 class CommitterRevertStatus(base.SimpleStatus): |
| 15 |
| 16 NO_COMMITTER = ( |
| 17 'Revert was not triggered by a project committer. Only full committers\n' |
| 18 'are accepted.' |
| 19 ) |
| 20 |
| 21 def __init__(self, pending, committers, **kwargs): |
| 22 super(CommitterRevertStatus, self).__init__(**kwargs) |
| 23 if pending: |
| 24 self._check(pending, committers) |
| 25 |
| 26 def _check(self, pending, committers): |
| 27 """Updates self.state and self.error_message properties.""" |
| 28 if any(re.match(i, pending.reverted_by) for i in committers): |
| 29 self.state = base.SUCCEEDED |
| 30 else: |
| 31 self.error_message = self.NO_COMMITTER |
| 32 self.state = base.FAILED |
| 33 |
| 34 |
| 35 class CommitterRevertVerifier(base.Verifier): |
| 36 """The revert must be triggered by a project committer.""" |
| 37 |
| 38 name = 'committer_revert' |
| 39 |
| 40 def __init__(self, committers): |
| 41 super(CommitterRevertVerifier, self).__init__() |
| 42 self.committers = committers |
| 43 |
| 44 def verify(self, pending): |
| 45 assert pending.revert |
| 46 pending.verifications[self.name] = CommitterRevertStatus( |
| 47 pending=pending, committers=self.committers) |
| 48 |
| 49 def update_status(self, queue): |
| 50 pass |
OLD | NEW |