Index: verification/committer_revert.py |
=================================================================== |
--- verification/committer_revert.py (revision 0) |
+++ verification/committer_revert.py (revision 0) |
@@ -0,0 +1,50 @@ |
+#!/usr/bin/env python |
+# Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+"""The revert checkbox must be checked by a project committer.""" |
+ |
+ |
+from verification import base |
+ |
+import re |
+ |
+ |
+class CommitterRevertStatus(base.SimpleStatus): |
+ |
+ NO_COMMITTER = ( |
+ 'Revert was not triggered by a project committer. Only full committers\n' |
+ 'are accepted.' |
+ ) |
+ |
+ def __init__(self, pending, committers, **kwargs): |
+ super(CommitterRevertStatus, self).__init__(**kwargs) |
+ if pending: |
+ self._check(pending, committers) |
+ |
+ def _check(self, pending, committers): |
+ """Updates self.state and self.error_message properties.""" |
+ if any(re.match(i, pending.reverted_by) for i in committers): |
+ self.state = base.SUCCEEDED |
+ else: |
+ self.error_message = self.NO_COMMITTER |
+ self.state = base.FAILED |
+ |
+ |
+class CommitterRevertVerifier(base.Verifier): |
+ """The revert must be triggered by a project committer.""" |
+ |
+ name = 'committer_revert' |
+ |
+ def __init__(self, committers): |
+ super(CommitterRevertVerifier, self).__init__() |
+ self.committers = committers |
+ |
+ def verify(self, pending): |
+ assert pending.revert |
+ pending.verifications[self.name] = CommitterRevertStatus( |
+ pending=pending, committers=self.committers) |
+ |
+ def update_status(self, queue): |
+ pass |
Property changes on: verification/committer_revert.py |
___________________________________________________________________ |
Added: svn:executable |
+ * |