Differential D18614 Diff 44694 src/applications/differential/controller/DifferentialRevisionOperationController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/controller/DifferentialRevisionOperationController.php
| Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | private function loadDefaultRef( | ||||
| PhabricatorRepository $repository, | PhabricatorRepository $repository, | ||||
| DifferentialDiff $diff) { | DifferentialDiff $diff) { | ||||
| $default_name = $this->getDefaultRefName($repository, $diff); | $default_name = $this->getDefaultRefName($repository, $diff); | ||||
| if (!strlen($default_name)) { | if (!strlen($default_name)) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| // NOTE: See PHI68. This is a workaround to make "Land Revision" work | return $this->newRefQuery($repository) | ||||
| // until T11823 is fixed properly. If we find multiple refs with the same | |||||
| // name (normally, duplicate "master" refs), just pick the first one. | |||||
| $refs = $this->newRefQuery($repository) | |||||
| ->withRefNames(array($default_name)) | ->withRefNames(array($default_name)) | ||||
| ->execute(); | ->executeOne(); | ||||
| if ($refs) { | |||||
| return head($refs); | |||||
| } | |||||
| return null; | |||||
| } | } | ||||
| private function getDefaultRefName( | private function getDefaultRefName( | ||||
| PhabricatorRepository $repository, | PhabricatorRepository $repository, | ||||
| DifferentialDiff $diff) { | DifferentialDiff $diff) { | ||||
| $onto = $diff->loadTargetBranch(); | $onto = $diff->loadTargetBranch(); | ||||
| if ($onto !== null) { | if ($onto !== null) { | ||||
| return $onto; | return $onto; | ||||
| } | } | ||||
| return $repository->getDefaultBranch(); | return $repository->getDefaultBranch(); | ||||
| } | } | ||||
| } | } | ||||