1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-19 16:58:48 +02:00

Differential - add a configuration option to allow any user to close a revision that has been accepted

Summary: this is useful for certain workflows, typically where the reviewer is a gatekeeper of sorts who does the acutal commit. Special thanks to D2900 which made this relatively brain-dead to code up.

Test Plan: set to "true" in my local development environment and verified test user "xerxes" could close my stuff

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1732

Differential Revision: https://secure.phabricator.com/D3398
This commit is contained in:
Bob Trahan 2012-08-28 14:17:23 -07:00
parent cdfc71ced5
commit 3aa54782a7
3 changed files with 15 additions and 3 deletions

View file

@ -1019,6 +1019,13 @@ return array(
// use of all of differential's features.
'differential.allow-self-accept' => false,
// If you set this to true, any user can close any revision so long as it has
// been accepted. This can be useful depending on your development model. For
// example, github-style pull requests where the reviewer is often the
// actual committer can benefit from turning this option to true. If false,
// only the submitter can close a revision.
'differential.always-allow-close' => false,
// Revisions newer than this number of days are marked as fresh in Action
// Required and Revisions Waiting on You views. Only work days (not weekends
// and holidays) are included. Set to 0 to disable this feature.

View file

@ -565,7 +565,9 @@ final class DifferentialRevisionViewController extends DifferentialController {
$status = $revision->getStatus();
$allow_self_accept = PhabricatorEnv::getEnvConfig(
'differential.allow-self-accept', false);
'differential.allow-self-accept', false);
$always_allow_close = PhabricatorEnv::getEnvConfig(
'differential.always-allow-close', false);
if ($viewer_is_owner) {
switch ($status) {
@ -613,6 +615,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
}
if ($status != ArcanistDifferentialRevisionStatus::CLOSED) {
$actions[DifferentialAction::ACTION_CLAIM] = true;
$actions[DifferentialAction::ACTION_CLOSE] = $always_allow_close;
}
}

View file

@ -118,7 +118,9 @@ final class DifferentialCommentEditor {
$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);
'differential.allow-self-accept', false);
$always_allow_close = PhabricatorEnv::getEnvConfig(
'differential.always-allow-close', false);
$revision_status = $revision->getStatus();
$revision->loadRelationships();
@ -349,7 +351,7 @@ final class DifferentialCommentEditor {
// them as completely authoritative.
if (!$this->isDaemonWorkflow) {
if (!$actor_is_author) {
if (!$actor_is_author && !$always_allow_close) {
throw new Exception(
"You can not mark a revision you don't own as closed.");
}