# HG changeset patch # User Thomas De Schampheleire # Date 2015-04-17 15:01:40 # Node ID 6b1e1437c026b79c548d39245810bf82a8c96733 # Parent 930caa6a4e5f5c8871486b0fe81354ec5bc77bb3 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 @@ class ChangesetStatusModel(BaseModel): 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 @@ class ChangesetStatusModel(BaseModel): 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 @@ class TestChangesetStatusCalculation(Bas ('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):