mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-09 06:11:01 +01:00
Allow revisions to be held as drafts, even after builds finish
Summary: Ref T2543. Instead of autosubmitting revisions to "Needs Review" when builds finish, allow them to be held in "Draft" indefinitely. There's currently no UI for this. I plan to just expose it as `arc diff --draft` for now, in a followup change. Test Plan: - Created a revision (via Conduit) with "hold as draft", saw it hold as draft after builds finished. - Created a revision (normally), saw it autosubmit after builds finished. - Requested review of a "hold as draft" revision to kick it out of draft state. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T2543 Differential Revision: https://secure.phabricator.com/D18737
This commit is contained in:
parent
f5336cd6e7
commit
28cec2f8a2
6 changed files with 81 additions and 1 deletions
|
@ -550,6 +550,7 @@ phutil_register_library_map(array(
|
|||
'DifferentialRevisionHasTaskRelationship' => 'applications/differential/relationships/DifferentialRevisionHasTaskRelationship.php',
|
||||
'DifferentialRevisionHeraldField' => 'applications/differential/herald/DifferentialRevisionHeraldField.php',
|
||||
'DifferentialRevisionHeraldFieldGroup' => 'applications/differential/herald/DifferentialRevisionHeraldFieldGroup.php',
|
||||
'DifferentialRevisionHoldDraftTransaction' => 'applications/differential/xaction/DifferentialRevisionHoldDraftTransaction.php',
|
||||
'DifferentialRevisionIDCommitMessageField' => 'applications/differential/field/DifferentialRevisionIDCommitMessageField.php',
|
||||
'DifferentialRevisionInlineTransaction' => 'applications/differential/xaction/DifferentialRevisionInlineTransaction.php',
|
||||
'DifferentialRevisionInlinesController' => 'applications/differential/controller/DifferentialRevisionInlinesController.php',
|
||||
|
@ -5592,6 +5593,7 @@ phutil_register_library_map(array(
|
|||
'DifferentialRevisionHasTaskRelationship' => 'DifferentialRevisionRelationship',
|
||||
'DifferentialRevisionHeraldField' => 'HeraldField',
|
||||
'DifferentialRevisionHeraldFieldGroup' => 'HeraldFieldGroup',
|
||||
'DifferentialRevisionHoldDraftTransaction' => 'DifferentialRevisionTransactionType',
|
||||
'DifferentialRevisionIDCommitMessageField' => 'DifferentialCommitMessageField',
|
||||
'DifferentialRevisionInlineTransaction' => 'PhabricatorModularTransactionType',
|
||||
'DifferentialRevisionInlinesController' => 'DifferentialController',
|
||||
|
|
|
@ -36,6 +36,12 @@ final class DifferentialDraftField
|
|||
return array();
|
||||
}
|
||||
|
||||
// If the author has held this revision as a draft explicitly, don't
|
||||
// show any misleading messages about it autosubmitting later.
|
||||
if ($revision->getHoldAsDraft()) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$warnings = array();
|
||||
|
||||
$blocking_map = array(
|
||||
|
|
|
@ -235,6 +235,22 @@ final class DifferentialRevisionEditEngine
|
|||
$fields[] = $action->newEditField($object, $viewer);
|
||||
}
|
||||
|
||||
$fields[] = id(new PhabricatorBoolEditField())
|
||||
->setKey('draft')
|
||||
->setLabel(pht('Hold as Draft'))
|
||||
->setIsConduitOnly(true)
|
||||
->setOptions(
|
||||
pht('Autosubmit Once Builds Finish'),
|
||||
pht('Hold as Draft'))
|
||||
->setTransactionType(
|
||||
DifferentialRevisionHoldDraftTransaction::TRANSACTIONTYPE)
|
||||
->setDescription(pht('Hold revision as as draft.'))
|
||||
->setConduitDescription(
|
||||
pht(
|
||||
'Change autosubmission from draft state after builds finish.'))
|
||||
->setConduitTypeDescription(pht('New "Hold as Draft" setting.'))
|
||||
->setValue($object->getHoldAsDraft());
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
|
|
@ -1540,7 +1540,7 @@ final class DifferentialTransactionEditor
|
|||
protected function didApplyTransactions($object, array $xactions) {
|
||||
// If a draft revision has no outstanding builds and we're automatically
|
||||
// making drafts public after builds finish, make the revision public.
|
||||
$auto_undraft = true;
|
||||
$auto_undraft = !$object->getHoldAsDraft();
|
||||
|
||||
if ($object->isDraft() && $auto_undraft) {
|
||||
$active_builds = $this->hasActiveBuilds($object);
|
||||
|
|
|
@ -57,6 +57,7 @@ final class DifferentialRevision extends DifferentialDAO
|
|||
const RELATION_SUBSCRIBED = 'subd';
|
||||
|
||||
const PROPERTY_CLOSED_FROM_ACCEPTED = 'wasAcceptedBeforeClose';
|
||||
const PROPERTY_DRAFT_HOLD = 'draft.hold';
|
||||
|
||||
public static function initializeNewRevision(PhabricatorUser $actor) {
|
||||
$app = id(new PhabricatorApplicationQuery())
|
||||
|
@ -708,6 +709,14 @@ final class DifferentialRevision extends DifferentialDAO
|
|||
return false;
|
||||
}
|
||||
|
||||
public function getHoldAsDraft() {
|
||||
return $this->getProperty(self::PROPERTY_DRAFT_HOLD, false);
|
||||
}
|
||||
|
||||
public function setHoldAsDraft($hold) {
|
||||
return $this->setProperty(self::PROPERTY_DRAFT_HOLD, $hold);
|
||||
}
|
||||
|
||||
public function loadActiveBuilds(PhabricatorUser $viewer) {
|
||||
$diff = $this->getActiveDiff();
|
||||
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
final class DifferentialRevisionHoldDraftTransaction
|
||||
extends DifferentialRevisionTransactionType {
|
||||
|
||||
const TRANSACTIONTYPE = 'draft';
|
||||
const EDITKEY = 'draft';
|
||||
|
||||
public function generateOldValue($object) {
|
||||
return (bool)$object->getHoldAsDraft();
|
||||
}
|
||||
|
||||
public function generateNewValue($object, $value) {
|
||||
return (bool)$value;
|
||||
}
|
||||
|
||||
public function applyInternalEffects($object, $value) {
|
||||
$object->setHoldAsDraft($value);
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
if ($this->getNewValue()) {
|
||||
return pht(
|
||||
'%s held this revision as a draft.',
|
||||
$this->renderAuthor());
|
||||
} else {
|
||||
return pht(
|
||||
'%s set this revision to automatically submit once builds complete.',
|
||||
$this->renderAuthor());
|
||||
}
|
||||
}
|
||||
|
||||
public function getTitleForFeed() {
|
||||
if ($this->getNewValue()) {
|
||||
return pht(
|
||||
'%s held %s as a draft.',
|
||||
$this->renderAuthor(),
|
||||
$this->renderObject());
|
||||
} else {
|
||||
return pht(
|
||||
'%s set %s to automatically submit once builds complete.',
|
||||
$this->renderAuthor(),
|
||||
$this->renderObject());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue