mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-09 16:32:39 +01:00
A closed commit can be reopened, if allowed by the config file.
Summary: Fixes T2316 Test Plan: When the config file allows reopening, navigate to a closed revision and reopen it in the user interface, and verify that the revision now "needs review." Also checks that the reopen option is unavailable when disallowed by the config file. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2316 Differential Revision: https://secure.phabricator.com/D4526
This commit is contained in:
parent
a8bd1f4998
commit
3802007082
5 changed files with 43 additions and 0 deletions
|
@ -1052,6 +1052,12 @@ return array(
|
|||
// only the submitter can close a revision.
|
||||
'differential.always-allow-close' => false,
|
||||
|
||||
// If you set this to true, any user can reopen a revision so long as it has
|
||||
// been closed. This can be useful if a revision is accidentally closed or
|
||||
// if a developer changes his or her mind after closing a revision. If it is
|
||||
// false, reopening is not allowed.
|
||||
'differential.allow-reopen' => 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.
|
||||
|
|
|
@ -183,6 +183,19 @@ final class PhabricatorDifferentialConfigOptions
|
|||
"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.")),
|
||||
$this->newOption('differential.allow-reopen', 'bool', false)
|
||||
->setBoolOptions(
|
||||
array(
|
||||
pht("Enable reopen"),
|
||||
pht("Disable reopen"),
|
||||
))
|
||||
->setSummary(pht("Allows any user to reopen a closed revision."))
|
||||
->setDescription(
|
||||
pht("If you set this to true, any user can reopen a revision so ".
|
||||
"long as it has been closed. This can be useful if a revision ".
|
||||
"is accidentally closed or if a developer changes his or her ".
|
||||
"mind after closing a revision. If it is false, reopening ".
|
||||
"is not allowed.")),
|
||||
$this->newOption('differential.days-fresh', 'int', 1)
|
||||
->setSummary(
|
||||
pht(
|
||||
|
|
|
@ -18,6 +18,7 @@ final class DifferentialAction {
|
|||
const ACTION_ADDREVIEWERS = 'add_reviewers';
|
||||
const ACTION_ADDCCS = 'add_ccs';
|
||||
const ACTION_CLAIM = 'claim';
|
||||
const ACTION_REOPEN = 'reopen';
|
||||
|
||||
public static function getActionPastTenseVerb($action) {
|
||||
$verbs = array(
|
||||
|
@ -37,6 +38,7 @@ final class DifferentialAction {
|
|||
self::ACTION_ADDREVIEWERS => 'added reviewers to',
|
||||
self::ACTION_ADDCCS => 'added CCs to',
|
||||
self::ACTION_CLAIM => 'commandeered',
|
||||
self::ACTION_REOPEN => 'reopened',
|
||||
);
|
||||
|
||||
if (!empty($verbs[$action])) {
|
||||
|
@ -60,6 +62,7 @@ final class DifferentialAction {
|
|||
self::ACTION_ADDCCS => 'Add CCs',
|
||||
self::ACTION_CLOSE => 'Close Revision',
|
||||
self::ACTION_CLAIM => 'Commandeer Revision',
|
||||
self::ACTION_REOPEN => 'Reopen',
|
||||
);
|
||||
|
||||
if (!empty($verbs[$action])) {
|
||||
|
|
|
@ -565,6 +565,8 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
|||
'differential.allow-self-accept', false);
|
||||
$always_allow_close = PhabricatorEnv::getEnvConfig(
|
||||
'differential.always-allow-close', false);
|
||||
$allow_reopen = PhabricatorEnv::getEnvConfig(
|
||||
'differential.allow-reopen', false);
|
||||
|
||||
if ($viewer_is_owner) {
|
||||
switch ($status) {
|
||||
|
@ -618,6 +620,8 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
|||
|
||||
$actions[DifferentialAction::ACTION_ADDREVIEWERS] = true;
|
||||
$actions[DifferentialAction::ACTION_ADDCCS] = true;
|
||||
$actions[DifferentialAction::ACTION_REOPEN] = $allow_reopen &&
|
||||
($status == ArcanistDifferentialRevisionStatus::CLOSED);
|
||||
|
||||
$actions = array_keys(array_filter($actions));
|
||||
$actions_dict = array();
|
||||
|
|
|
@ -102,6 +102,8 @@ final class DifferentialCommentEditor extends PhabricatorEditor {
|
|||
'differential.allow-self-accept', false);
|
||||
$always_allow_close = PhabricatorEnv::getEnvConfig(
|
||||
'differential.always-allow-close', false);
|
||||
$allow_reopen = PhabricatorEnv::getEnvConfig(
|
||||
'differential.allow-reopen', false);
|
||||
$revision_status = $revision->getStatus();
|
||||
|
||||
$revision->loadRelationships();
|
||||
|
@ -360,6 +362,21 @@ final class DifferentialCommentEditor extends PhabricatorEditor {
|
|||
$revision->setStatus(ArcanistDifferentialRevisionStatus::CLOSED);
|
||||
break;
|
||||
|
||||
case DifferentialAction::ACTION_REOPEN:
|
||||
if (!$allow_reopen) {
|
||||
throw new Exception(
|
||||
"You cannot reopen a revision when this action is disabled.");
|
||||
}
|
||||
|
||||
if ($revision_status != ArcanistDifferentialRevisionStatus::CLOSED) {
|
||||
throw new Exception(
|
||||
"You cannot reopen a revision that is not currently closed.");
|
||||
}
|
||||
|
||||
$revision->setStatus(ArcanistDifferentialRevisionStatus::NEEDS_REVIEW);
|
||||
|
||||
break;
|
||||
|
||||
case DifferentialAction::ACTION_ADDREVIEWERS:
|
||||
list($added_reviewers, $ignored) = $this->alterReviewers();
|
||||
|
||||
|
|
Loading…
Reference in a new issue