Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15426620
D14734.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D14734.diff
View Options
diff --git a/src/applications/differential/controller/DifferentialRevisionOperationController.php b/src/applications/differential/controller/DifferentialRevisionOperationController.php
--- a/src/applications/differential/controller/DifferentialRevisionOperationController.php
+++ b/src/applications/differential/controller/DifferentialRevisionOperationController.php
@@ -30,26 +30,28 @@
$diff = $revision->getActiveDiff();
$repository = $revision->getRepository();
- $ref_types = array(
- PhabricatorRepositoryRefCursor::TYPE_BRANCH,
- );
+ $default_ref = $this->loadDefaultRef($repository);
+
+ if ($default_ref) {
+ $v_ref = array($default_ref->getPHID());
+ } else {
+ $v_ref = array();
+ }
$e_ref = true;
$errors = array();
if ($request->isFormPost()) {
- $ref_phid = head($request->getArr('refPHIDs'));
+ $v_ref = $request->getArr('refPHIDs');
+ $ref_phid = head($v_ref);
if (!strlen($ref_phid)) {
$e_ref = pht('Required');
$errors[] = pht(
'You must select a branch to land this revision onto.');
} else {
- $ref = id(new PhabricatorRepositoryRefCursorQuery())
- ->setViewer($viewer)
+ $ref = $this->newRefQuery($repository)
->withPHIDs(array($ref_phid))
- ->withRepositoryPHIDs(array($repository->getPHID()))
- ->withRefTypes($ref_types)
->executeOne();
if (!$ref) {
$e_ref = pht('Invalid');
@@ -85,7 +87,7 @@
->setParameters(
array(
'repositoryPHIDs' => array($repository->getPHID()),
- 'refTypes' => $ref_types,
+ 'refTypes' => $this->getTargetableRefTypes(),
));
$form = id(new AphrontFormView())
@@ -100,6 +102,7 @@
->setName('refPHIDs')
->setLimit(1)
->setError($e_ref)
+ ->setValue($v_ref)
->setDatasource($ref_datasource))
->appendRemarkupInstructions(
pht(
@@ -115,4 +118,35 @@
->addSubmitButton(pht('Mutate Repository Unpredictably'));
}
+ private function newRefQuery(PhabricatorRepository $repository) {
+ $viewer = $this->getViewer();
+
+ return id(new PhabricatorRepositoryRefCursorQuery())
+ ->setViewer($viewer)
+ ->withRepositoryPHIDs(array($repository->getPHID()))
+ ->withRefTypes($this->getTargetableRefTypes());
+ }
+
+ private function getTargetableRefTypes() {
+ return array(
+ PhabricatorRepositoryRefCursor::TYPE_BRANCH,
+ );
+ }
+
+ private function loadDefaultRef(PhabricatorRepository $repository) {
+ $default_name = $this->getDefaultRefName($repository);
+
+ if (!strlen($default_name)) {
+ return null;
+ }
+
+ return $this->newRefQuery($repository)
+ ->withRefNames(array($default_name))
+ ->executeOne();
+ }
+
+ private function getDefaultRefName(PhabricatorRepository $repository) {
+ return $repository->getDefaultBranch();
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 24, 10:05 AM (4 d, 10 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7387841
Default Alt Text
D14734.diff (2 KB)
Attached To
Mode
D14734: Default "Land Revision" dialog to land into the default branch for the repository
Attached
Detach File
Event Timeline
Log In to Comment