Skip to content
This repository has been archived by the owner on Jul 30, 2023. It is now read-only.

Commit

Permalink
Opt-in approve your own Differential revisions
Browse files Browse the repository at this point in the history
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
  • Loading branch information
floatingLomas authored and epriestley committed Jul 3, 2012
1 parent 948259e commit c821639
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion conf/default.conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -943,12 +943,17 @@
'differential.anonymous-access' => false,

// 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(
// '/config\.h$/',
// '#/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 ------------------------------------------------------------- //

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,13 +536,18 @@ private function getRevisionCommentActions(DifferentialRevision $revision) {
$viewer_did_accept = ($viewer_phid === $revision->loadReviewedBy());
$status = $revision->getStatus();

$allow_self_accept = PhabricatorEnv::getEnvConfig(
'differential.allow-self-accept', false);

if ($viewer_is_owner) {
switch ($status) {
case ArcanistDifferentialRevisionStatus::NEEDS_REVIEW:
$actions[DifferentialAction::ACTION_ACCEPT] = $allow_self_accept;
$actions[DifferentialAction::ACTION_ABANDON] = true;
$actions[DifferentialAction::ACTION_RETHINK] = true;
break;
case ArcanistDifferentialRevisionStatus::NEEDS_REVISION:
$actions[DifferentialAction::ACTION_ACCEPT] = $allow_self_accept;
$actions[DifferentialAction::ACTION_ABANDON] = true;
$actions[DifferentialAction::ACTION_REQUEST] = true;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public function save() {
$actor_phid = $this->actorPHID;
$actor = id(new PhabricatorUser())->loadOneWhere('PHID = %s', $actor_phid);
$actor_is_author = ($actor_phid == $revision->getAuthorPHID());
$allow_self_accept = PhabricatorEnv::getEnvConfig(
'differential.allow-self-accept', false);
$revision_status = $revision->getStatus();

$revision->loadRelationships();
Expand Down Expand Up @@ -176,7 +178,7 @@ public function save() {
break;

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.');
}
if (($revision_status !=
Expand Down

0 comments on commit c821639

Please sign in to comment.