mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Opt-in approve your own Differential revisions
Summary: Did exactly what @epriestley suggested in T1428#2. Test Plan: Turn it on in your config, post a revision, accept it. Turn it off in your config, post a revision, can't accept it. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D2900
This commit is contained in:
parent
948259ee92
commit
c821639e93
3 changed files with 14 additions and 2 deletions
|
@ -943,12 +943,17 @@ return array(
|
||||||
'differential.anonymous-access' => false,
|
'differential.anonymous-access' => false,
|
||||||
|
|
||||||
// List of file regexps that should be treated as if they are generated by
|
// List of file regexps that should be treated as if they are generated by
|
||||||
// an automatic process, and thus get hidden by default in differential
|
// an automatic process, and thus get hidden by default in differential.
|
||||||
'differential.generated-paths' => array(
|
'differential.generated-paths' => array(
|
||||||
// '/config\.h$/',
|
// '/config\.h$/',
|
||||||
// '#/autobuilt/#',
|
// '#/autobuilt/#',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// If you set this to true, users can accept their own revisions. This action
|
||||||
|
// is disabled by default because it's most likely not a behavior you want,
|
||||||
|
// but it proves useful if you are working alone on a project and want to make
|
||||||
|
// use of all of differential's features.
|
||||||
|
'differential.allow-self-accept' => false,
|
||||||
|
|
||||||
// -- Maniphest ------------------------------------------------------------- //
|
// -- Maniphest ------------------------------------------------------------- //
|
||||||
|
|
||||||
|
|
|
@ -536,13 +536,18 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||||
$viewer_did_accept = ($viewer_phid === $revision->loadReviewedBy());
|
$viewer_did_accept = ($viewer_phid === $revision->loadReviewedBy());
|
||||||
$status = $revision->getStatus();
|
$status = $revision->getStatus();
|
||||||
|
|
||||||
|
$allow_self_accept = PhabricatorEnv::getEnvConfig(
|
||||||
|
'differential.allow-self-accept', false);
|
||||||
|
|
||||||
if ($viewer_is_owner) {
|
if ($viewer_is_owner) {
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW:
|
case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW:
|
||||||
|
$actions[DifferentialAction::ACTION_ACCEPT] = $allow_self_accept;
|
||||||
$actions[DifferentialAction::ACTION_ABANDON] = true;
|
$actions[DifferentialAction::ACTION_ABANDON] = true;
|
||||||
$actions[DifferentialAction::ACTION_RETHINK] = true;
|
$actions[DifferentialAction::ACTION_RETHINK] = true;
|
||||||
break;
|
break;
|
||||||
case ArcanistDifferentialRevisionStatus::NEEDS_REVISION:
|
case ArcanistDifferentialRevisionStatus::NEEDS_REVISION:
|
||||||
|
$actions[DifferentialAction::ACTION_ACCEPT] = $allow_self_accept;
|
||||||
$actions[DifferentialAction::ACTION_ABANDON] = true;
|
$actions[DifferentialAction::ACTION_ABANDON] = true;
|
||||||
$actions[DifferentialAction::ACTION_REQUEST] = true;
|
$actions[DifferentialAction::ACTION_REQUEST] = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -111,6 +111,8 @@ final class DifferentialCommentEditor {
|
||||||
$actor_phid = $this->actorPHID;
|
$actor_phid = $this->actorPHID;
|
||||||
$actor = id(new PhabricatorUser())->loadOneWhere('PHID = %s', $actor_phid);
|
$actor = id(new PhabricatorUser())->loadOneWhere('PHID = %s', $actor_phid);
|
||||||
$actor_is_author = ($actor_phid == $revision->getAuthorPHID());
|
$actor_is_author = ($actor_phid == $revision->getAuthorPHID());
|
||||||
|
$allow_self_accept = PhabricatorEnv::getEnvConfig(
|
||||||
|
'differential.allow-self-accept', false);
|
||||||
$revision_status = $revision->getStatus();
|
$revision_status = $revision->getStatus();
|
||||||
|
|
||||||
$revision->loadRelationships();
|
$revision->loadRelationships();
|
||||||
|
@ -176,7 +178,7 @@ final class DifferentialCommentEditor {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DifferentialAction::ACTION_ACCEPT:
|
case DifferentialAction::ACTION_ACCEPT:
|
||||||
if ($actor_is_author) {
|
if ($actor_is_author && !$allow_self_accept) {
|
||||||
throw new Exception('You can not accept your own revision.');
|
throw new Exception('You can not accept your own revision.');
|
||||||
}
|
}
|
||||||
if (($revision_status !=
|
if (($revision_status !=
|
||||||
|
|
Loading…
Reference in a new issue