Differential D14737 Diff 35645 src/applications/differential/controller/DifferentialRevisionOperationController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/controller/DifferentialRevisionOperationController.php
| Show All 24 Lines | if ($barrier) { | ||||
| ->setTitle($barrier['title']) | ->setTitle($barrier['title']) | ||||
| ->appendParagraph($barrier['body']) | ->appendParagraph($barrier['body']) | ||||
| ->addCancelButton($detail_uri); | ->addCancelButton($detail_uri); | ||||
| } | } | ||||
| $diff = $revision->getActiveDiff(); | $diff = $revision->getActiveDiff(); | ||||
| $repository = $revision->getRepository(); | $repository = $revision->getRepository(); | ||||
| $default_ref = $this->loadDefaultRef($repository); | $default_ref = $this->loadDefaultRef($repository, $diff); | ||||
| if ($default_ref) { | if ($default_ref) { | ||||
| $v_ref = array($default_ref->getPHID()); | $v_ref = array($default_ref->getPHID()); | ||||
| } else { | } else { | ||||
| $v_ref = array(); | $v_ref = array(); | ||||
| } | } | ||||
| $e_ref = true; | $e_ref = true; | ||||
| ▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | final class DifferentialRevisionOperationController | ||||
| } | } | ||||
| private function getTargetableRefTypes() { | private function getTargetableRefTypes() { | ||||
| return array( | return array( | ||||
| PhabricatorRepositoryRefCursor::TYPE_BRANCH, | PhabricatorRepositoryRefCursor::TYPE_BRANCH, | ||||
| ); | ); | ||||
| } | } | ||||
| private function loadDefaultRef(PhabricatorRepository $repository) { | private function loadDefaultRef( | ||||
| $default_name = $this->getDefaultRefName($repository); | PhabricatorRepository $repository, | ||||
| DifferentialDiff $diff) { | |||||
| $default_name = $this->getDefaultRefName($repository, $diff); | |||||
| if (!strlen($default_name)) { | if (!strlen($default_name)) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| return $this->newRefQuery($repository) | return $this->newRefQuery($repository) | ||||
| ->withRefNames(array($default_name)) | ->withRefNames(array($default_name)) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| } | } | ||||
| private function getDefaultRefName(PhabricatorRepository $repository) { | private function getDefaultRefName( | ||||
| PhabricatorRepository $repository, | |||||
| DifferentialDiff $diff) { | |||||
| $onto = $diff->loadTargetBranch(); | |||||
| if ($onto !== null) { | |||||
| return $onto; | |||||
| } | |||||
| return $repository->getDefaultBranch(); | return $repository->getDefaultBranch(); | ||||
| } | } | ||||
| } | } | ||||