Differential D18412 Diff 44256 src/applications/differential/xaction/DifferentialRevisionCloseTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/xaction/DifferentialRevisionCloseTransaction.php
| Show All 40 Lines | public function applyInternalEffects($object, $value) { | ||||
| $object->setStatus($status_closed); | $object->setStatus($status_closed); | ||||
| $object->setProperty( | $object->setProperty( | ||||
| DifferentialRevision::PROPERTY_CLOSED_FROM_ACCEPTED, | DifferentialRevision::PROPERTY_CLOSED_FROM_ACCEPTED, | ||||
| $was_accepted); | $was_accepted); | ||||
| } | } | ||||
| protected function validateAction($object, PhabricatorUser $viewer) { | protected function validateAction($object, PhabricatorUser $viewer) { | ||||
| if ($this->getEditor()->getIsCloseByCommit()) { | |||||
| // If we're closing a revision because we discovered a commit, we don't | |||||
| // care what state it was in. | |||||
| return; | |||||
| } | |||||
| if ($object->isClosed()) { | if ($object->isClosed()) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'You can not close this revision because it has already been '. | 'You can not close this revision because it has already been '. | ||||
| 'closed. Only open revisions can be closed.')); | 'closed. Only open revisions can be closed.')); | ||||
| } | } | ||||
| if (!$object->isAccepted()) { | if (!$object->isAccepted()) { | ||||
| Show All 12 Lines | if (!PhabricatorEnv::getEnvConfig($config_key)) { | ||||
| 'author. You can only close revisions you own. You can change '. | 'author. You can only close revisions you own. You can change '. | ||||
| 'this behavior by adjusting the "%s" setting in Config.', | 'this behavior by adjusting the "%s" setting in Config.', | ||||
| $config_key)); | $config_key)); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| public function getTitle() { | public function getTitle() { | ||||
| if (!$this->getMetadataValue('isCommitClose')) { | |||||
| return pht( | return pht( | ||||
| '%s closed this revision.', | '%s closed this revision.', | ||||
| $this->renderAuthor()); | $this->renderAuthor()); | ||||
| } | } | ||||
| $commit_phid = $this->getMetadataValue('commitPHID'); | |||||
| $committer_phid = $this->getMetadataValue('committerPHID'); | |||||
| $author_phid = $this->getMetadataValue('authorPHID'); | |||||
| if ($committer_phid) { | |||||
| $committer_name = $this->renderHandle($committer_phid); | |||||
| } else { | |||||
| $committer_name = $this->getMetadataValue('committerName'); | |||||
| } | |||||
| if ($author_phid) { | |||||
| $author_name = $this->renderHandle($author_phid); | |||||
| } else { | |||||
| $author_name = $this->getMetadatavalue('authorName'); | |||||
| } | |||||
| $same_phid = | |||||
| strlen($committer_phid) && | |||||
| strlen($author_phid) && | |||||
| ($committer_phid == $author_phid); | |||||
| $same_name = | |||||
| !strlen($committer_phid) && | |||||
| !strlen($author_phid) && | |||||
| ($committer_name == $author_name); | |||||
| if ($same_name || $same_phid) { | |||||
| return pht( | |||||
| 'Closed by commit %s (authored by %s).', | |||||
| $this->renderHandle($commit_phid), | |||||
| $author_name); | |||||
| } else { | |||||
| return pht( | |||||
| 'Closed by commit %s (authored by %s, committed by %s).', | |||||
| $this->renderHandle($commit_phid), | |||||
| $author_name, | |||||
| $committer_name); | |||||
| } | |||||
| } | |||||
| public function getTitleForFeed() { | public function getTitleForFeed() { | ||||
| return pht( | return pht( | ||||
| '%s closed %s.', | '%s closed %s.', | ||||
| $this->renderAuthor(), | $this->renderAuthor(), | ||||
| $this->renderObject()); | $this->renderObject()); | ||||
| } | } | ||||
| } | } | ||||