[PATCH 3 of 3] changeset status: set status to rejected if at least one reviewer rejected

Thomas De Schampheleire patrickdepinguin at gmail.com
Sat Apr 18 16:11:53 EDT 2015


# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1429275700 -7200
#      Fri Apr 17 15:01:40 2015 +0200
# Node ID e721e300d713a00747e6c519a98b38ef931b0f40
# Parent  a37093840d5181cfbfe3e3b730525945054c15a2
changeset status: set status to rejected if at least one reviewer rejected

Currently, a reject of a change by a reviewer does not affect the overall
status at all. A logical policy is to reject the change if at least one
reviewer rejects it.

Note: different repositories/organizations may require different policies
for the overall status. Currently, the policies for approve/reject are
fixed. A possible improvement is to provide several alternative
policies and allow selecting the policy per instance or per repo.

diff --git a/kallithea/model/changeset_status.py b/kallithea/model/changeset_status.py
--- a/kallithea/model/changeset_status.py
+++ b/kallithea/model/changeset_status.py
@@ -69,7 +69,7 @@
     def _calculate_status(self, statuses):
         """
         Given a list of statuses, calculate the resulting status, according to
-        the policy: approve if consensus.
+        the policy: approve if consensus, reject when at least one reject.
         """
 
         if not statuses:
@@ -78,6 +78,9 @@
         if all(st.status == ChangesetStatus.STATUS_APPROVED for st in statuses):
             return ChangesetStatus.STATUS_APPROVED
 
+        if any(st.status == ChangesetStatus.STATUS_REJECTED for st in statuses):
+            return ChangesetStatus.STATUS_REJECTED
+
         return ChangesetStatus.STATUS_UNDER_REVIEW
 
     def calculate_pull_request_result(self, pull_request):
diff --git a/kallithea/tests/models/test_changeset_status.py b/kallithea/tests/models/test_changeset_status.py
--- a/kallithea/tests/models/test_changeset_status.py
+++ b/kallithea/tests/models/test_changeset_status.py
@@ -24,13 +24,13 @@
         ('empty list', STATUS_UNDER_REVIEW, []),
         ('approve', STATUS_APPROVED, [S(STATUS_APPROVED)]),
         ('approve2', STATUS_APPROVED, [S(STATUS_APPROVED), S(STATUS_APPROVED)]),
-        ('approve_reject', STATUS_UNDER_REVIEW, [S(STATUS_APPROVED), S(STATUS_REJECTED)]),
+        ('approve_reject', STATUS_REJECTED, [S(STATUS_APPROVED), S(STATUS_REJECTED)]),
         ('approve_underreview', STATUS_UNDER_REVIEW, [S(STATUS_APPROVED), S(STATUS_UNDER_REVIEW)]),
         ('approve_notreviewed', STATUS_UNDER_REVIEW, [S(STATUS_APPROVED), S(STATUS_NOT_REVIEWED)]),
         ('underreview', STATUS_UNDER_REVIEW, [S(STATUS_UNDER_REVIEW), S(STATUS_UNDER_REVIEW)]),
-        ('reject', STATUS_UNDER_REVIEW, [S(STATUS_REJECTED)]),
-        ('reject_underreview', STATUS_UNDER_REVIEW, [S(STATUS_REJECTED), S(STATUS_UNDER_REVIEW)]),
-        ('reject_notreviewed', STATUS_UNDER_REVIEW, [S(STATUS_REJECTED), S(STATUS_NOT_REVIEWED)]),
+        ('reject', STATUS_REJECTED, [S(STATUS_REJECTED)]),
+        ('reject_underreview', STATUS_REJECTED, [S(STATUS_REJECTED), S(STATUS_UNDER_REVIEW)]),
+        ('reject_notreviewed', STATUS_REJECTED, [S(STATUS_REJECTED), S(STATUS_NOT_REVIEWED)]),
         ('notreviewed', STATUS_UNDER_REVIEW, [S(STATUS_NOT_REVIEWED)]),
     ])
     def test_result(self, name, expected_result, statuses):


More information about the kallithea-general mailing list