Mercurial > kallithea
changeset 5041:6b1e1437c026
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.
author | Thomas De Schampheleire <thomas.de.schampheleire@gmail.com> |
---|---|
date | Fri, 17 Apr 2015 15:01:40 +0200 |
parents | 930caa6a4e5f |
children | 30c6d2ebf310 |
files | kallithea/model/changeset_status.py kallithea/tests/models/test_changeset_status.py |
diffstat | 2 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/model/changeset_status.py Fri Apr 17 14:58:44 2015 +0200 +++ b/kallithea/model/changeset_status.py Fri Apr 17 15:01:40 2015 +0200 @@ -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):
--- a/kallithea/tests/models/test_changeset_status.py Fri Apr 17 14:58:44 2015 +0200 +++ b/kallithea/tests/models/test_changeset_status.py Fri Apr 17 15:01:40 2015 +0200 @@ -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):